Ruby Gem

miiCard has developed a Ruby gem that wraps the miiCard API to simplify making OAuth-authorised requests. It is available on RubyGems.org and it's also open-source, hosted on GitHub.

The library takes a dependency on the Ruby OAuth Gem.

Download options

Usage

You'll need to implement your own OAuth exchange with miiCard.com's OAuth endpoint to obtain an access token and secret for a user. Once you've got your consumer key and secret, access token and access token secret you can instantiate an API wrapper:

api = MiiCardOAuthClaimsService.new(
                                     "consumer_key", 
                                     "consumer_secret", 
                                     "access_token", 
                                     "access_token_secret"
                                   )

Then make calls against it simply:

user_profile_response = api.get_claims().data

user_first_name = user_profile_response.data.first_name

Mapping from API data types

The following list is provided as a convenient cheat-sheet, and maps the API's methods and data types to their equivalents in the Ruby wrapper library classes.

Methods

API method Ruby equivalent (given api instance of MiiCardOAuthClaimsService)
AssuranceImage api.assurance_image(type)
GetCardImage api.get_card_image(snapshot_id, show_email_address, show_phone_number, format)
GetClaims api.get_claims()
GetIdentitySnapshot api.get_identity_snapshot(snapshot_id)
GetIdentitySnapshotDetails api.get_identity_snapshot_details()
Or, for a specific snapshot:
api.get_identity_snapshot_details(snapshot_id)
GetIdentitySnapshotPdf api.get_identity_snapshot_pdf(snapshot_id)
IsSocialAccountAssured api.is_social_account_assured(social_account_id, social_account_type)
IsUserAssured api.is_user_assured()

Data types

EmailAddress

API data-type property Ruby equivalent (given email instance of EmailAddress)
DisplayName email.display_name
Address email.address
IsPrimary email.is_primary
Verified email.verified

Identity

API data-type property Ruby equivalent (given identity instance of Identity)
Source identity.source
UserId identity.user_id
ProfileUrl identity.profile_url
Verified identity.verified

IdentitySnapshot

API data-type property Ruby equivalent (given snapshot instance of IdentitySnapshot)
Details snapshot.details
Snapshot snapshot.snapshot

IdentitySnapshotDetails

API data-type property Ruby equivalent (given snapshot_details instance of IdentitySnapshotDetails)
SnapshotId snapshot_details.snapshot_id
Username snapshot_details.username
TimestampUtc snapshot_details.timestamp_utc
WasTestUser snapshot_details.was_test_user

MiiApiCallStatus enumeration type

API data-type property Ruby equivalent
Success MiiApiCallStatus.SUCCESS
Failure MiiApiCallStatus.FAILURE

MiiApiErrorCode enumeration type

API data-type property Ruby equivalent
Success MiiApiCallStatus.SUCCESS
AccessRevoked MiiApiCallStatus.ACCESS_REVOKED
UserSubscriptionLapsed MiiApiCallStatus.USER_SUBSCRIPTION_LAPSED
TransactionalSupportDisabled MiiApiCallStatus.TRANSATIONAL_SUPPORT_DISABLED
DevelopmentTransactionalSupportOnly MiiApiCallStatus.DEVELOPMENT_TRANSACTIONAL_SUPPORT_ONLY
InvalidSnapshotId MiiApiCallStatus.INVALID_SNAPSHOT_ID
Blacklisted MiiApiCallStatus.BLACKLISTED
ProductDisabled MiiApiCallStatus.PRODUCT_DISABLED
ProductDeleted MiiApiCallStatus.PRODUCT_DELETED
Exception MiiApiCallStatus.EXCEPTION

MiiApiResponse

API data-type property Ruby equivalent (given response instance of MiiApiResponse)
Status response.status
ErrorCode response.error_code
ErrorMessage response.error_message
Data response.data
IsTestUser response.is_test_user

MiiUserProfile

API data-type property Ruby equivalent (given profile instance of MiiUserProfile)
Salutation profile.salutation
FirstName profile.first_name
MiddleName profile.middle_name
LastName profile.last_name
DateOfBirth profile.date_of_birth
PreviousFirstName profile.previous_first_name
PreviousMiddleName profile.previous_middle_name
PreviousLastName profile.previous_last_name
LastVerified profile.last_verified
ProfileUrl profile.profile_url
ProfileShortUrl profile.profile_short_url
CardImageUrl profile.card_image_url
EmailAddresses profile.email_addresses
Identities profile.identities
PhoneNumbers profile.phone_numbers
PostalAddresses profile.postal_addresses
WebProperties profile.web_properties
IdentityAssured profile.identity_assured
HasPublicProfile profile.has_public_profile
PublicProfile profile.public_profile

PhoneNumber

API data-type property Ruby equivalent (given phone instance of PhoneNumber)
DisplayName phone.display_name
CountryCode phone.country_code
NationalNumber phone.national_number
IsMobile phone.is_mobile
IsPrimary phone.is_primary
Verified phone.verified

PostalAddress

API data-type property Ruby equivalent (given address instance of PostalAddress)
House address.house
Line1 address.line1
Line2 address.line2
City address.city
Region address.region
Code address.code
Country address.country
IsPrimary address.is_primary
Verified address.verified

WebProperty

API data-type property Ruby equivalent (given property instance of WebProperty)
DisplayName property.display_name
Identifier property.identifier
Type property.type
Verified property.verified

WebPropertyType enumeration type

API data-type property Ruby equivalent
Domain WebPropertyType.DOMAIN
Website WebPropertyType.WEBSITE