项目作者: ManojmoreS

项目描述 :
Ruby client for Singapore MyInfo API.
高级语言: Ruby
项目地址: git://github.com/ManojmoreS/myinfo_ruby.git
创建时间: 2019-03-20T16:38:36Z
项目社区:https://github.com/ManojmoreS/myinfo_ruby

开源协议:MIT License

下载


MyinfoRuby

A ruby client :gem: to interact with MyInfo API :purple_heart:.

About MyInfo:

MyInfo - Designed by the Singapore Government, MyInfo is a service that enables citizens and residents to manage the use of their personal data for simpler online transactions. Users control and consent to the sharing of their data, and can view a record of past usage. MyInfo users will enjoy less form-filling and a reduced need for providing verifying documentation during online transactions.

MyInfo api integration : https://www.ndi-api.gov.sg/library/trusted-data/myinfo/introduction

Installation

Add this line to your application’s Gemfile:

  1. gem 'myinfo_ruby'

And then execute:

  1. $ bundle

Or install it yourself as:

  1. $ gem install myinfo_ruby

Usage

  1. config = {
  2. token_url: '',
  3. personal_url: '',
  4. code: '', # Code returned from authorise process.
  5. private_key: '', # Key generated while CSR for ssl purpose.
  6. client_id: '', # Client id provided by ndi-api.
  7. client_secret: '', # Client secret provided by ndi-api.
  8. attributes: '', # Attributes to be fetched from Api.
  9. redirect_url: '',# Redirect_url setup on ndi-api.
  10. auth_level: 'L2' #L2 if your using PKI signature, L0 if normal authorisation.
  11. }
  12. # Testing
  13. key = File.read('./testing_private_key.pem')
  14. config = {
  15. token_url: "https://test.api.myinfo.gov.sg/com/v3/token",
  16. personal_url: "https://test.api.myinfo.gov.sg/com/v3/person",
  17. code: '', # Code returned from authorise process.
  18. private_key: key,
  19. client_id: 'STG2-MYINFO-SELF-TEST',
  20. client_secret: '44d953c796cccebcec9bdc826852857ab412fbe2',
  21. attributes: 'name,aliasname,hanyupinyinname,hanyupinyinaliasname,dob',
  22. redirect_url: 'http://localhost:3001',
  23. auth_level: 'L2'
  24. }
  25. myinfo_client = MyinfoRuby::Client.new config
  26. personal_data = myinfo_client.fetch_personal

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/myinfo_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the MyinfoRuby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.