Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mais_orcid_client

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mais_orcid_client

  • 0.3.1
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

Gem Version CircleCI Maintainability Test Coverage

mais_orcid_client

API client for accessing MAIS's ORCID endpoints.

MAIS's ORCID API provides access to ORCID information for Stanford users. (This is different from orcid.org's ORCID API, which is supported by https://github.com/sul-dlss/orcid_client.)

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add mais_orcid_client

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install mais_orcid_client

Usage

For one-off requests:

require "mais_orcid_client"

# NOTE: The settings below live in the consumer, not in the gem.
client = MaisOrcidClient.configure(
  client_id: Settings.mais_orcid.client_id,
  client_secret: Settings.mais_orcid.client_secret,
  base_url: Settings.mais_orcid.base_url
)
client.fetch_orcid_user(sunetid: 'nataliex')

You can also invoke methods directly on the client class, which is useful in a Rails application environment where you might initialize the client in an initializer and then invoke client methods in many other contexts where you want to be sure configuration has already occurred, e.g.:

# config/initializers/mais_orcid_client.rb
MaisOrcidClient.configure(
  client_id: Settings.mais_orcid.client_id,
  client_secret: Settings.mais_orcid.client_secret,
  base_url: Settings.mais_orcid.base_url
)

# app/services/my_mais_orcid_service.rb
# ...
def create_user_directory
  MaisOrcidClient.fetch_orcid_user(sunetid: 'nataliex')
end
# ...

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 the created tag, and push the .gem file to rubygems.org.

VCR Cassettes

VCR gem is used to record the results of the API calls for the tests. If you need to record or re-create existing cassettes, you may need to adjust expectations in the tests as the results coming back from the API may be different than when the cassettes were recorded.

To record new cassettes:

  1. Temporarily adjust the configuration (client_id, client_secret for the MaIS UAT URL) at the top of spec/mais_orcid_client_spec.rb so it matches the real MaIS UAT environment.
  2. Add your new spec with a new cassette name (or delete a previous cassette to re-create it).
  3. Run just that new spec (important: else previous specs may use cassettes that have redacted credentials, causing your new spec to fail).
  4. You should get a new cassette with the name you specified in the spec.
  5. The cassette should have access tokens and secrets sanitized by the config in spec_helper.rb, but you can double check, EXCEPT for user access tokens in the user response. These should be sanitized manaully (e.g. "access_token":"8d13b8bb-XXXX-YYYY-b7d6-87aecd5a8975")
  6. Set your configuration at the top of the spec back to the fake client_id and client_secret values.
  7. Re-run all the specs - they should pass now without making real calls.

FAQs

Package last updated on 17 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc