Build Status Code ClimateCoverage Status

Access API

A ruby wrapper for the Access API

Installation

  gem 'access', '~> 2.0.0'

And then execute:

$ bundle

Or install it yourself as:

$ gem install access

Setup

Config setup

You can configure the following options:

  • access_token Required
  • api_environment: Set as 'demo' or 'production'. Default is 'demo'.
  • return_json: Set as 'true' or 'false'. Default is 'false' return ruby objects.
  • hashify: Set as 'true' or 'false'. Default is 'false' return a hashed version of the json response if return_json is set to 'true'.
  • access_timeout: Set as a number. Default to '10'.
  • access_debug_output: Set as a string 'true' or 'false'. Default is 'false'. When 'true' it will write out the raw request response from the httparty call.

Config via Environment Variables

You can set config settings by creating environment variables called:

ENV['ACCESS_TOKEN'], ENV['ACCESS_ENVIRONMENT'], ENV['ACCESS_RETURN_JSON'], ENV['ACCESS_HASHIFY'], ENV['ACCESS_TIMEOUT'], ENV['ACCESS_DEBUG_OUTPUT'].

Config via Initializer

You can also create an initializer file to set up a config

Access.configure do |config|
  config.access_token = ENV['ACCESS_TOKEN']
end

You can also set them one at a time

Access.config.access_token = ENV['ACCESS_TOKEN']

Config via Params

api_environment can be overwritten by passing in by passing the param api_environment to the end of any call that accepts options.

access_timeout can be overwritten by passing in by passing the param access_timeout to the end of any call that accepts options.

access_token can be overwritten by passing in by passing the param access_token to the end of any call that accepts options.

return_json can be overwritten by passing in by passing the param return_json to the end of any call that accepts options.

hashify can be overwritten by passing in by passing the param hashify to the end of any call that accepts options.

access_debug_output can be overwritten by passing in by passing the param access_debug_output to the end of any call that accepts options.

Making Calls

Offer

Access::Offer.search options, member_key: **your-member-key**
Access::Offer.find **offer_key**, options, member_key: **your-member-key**

Store

Access::Store.search options, member_key: **your-member-key**
Access::Store.find **store_key**, options, member_key: **your-member-key**
Access::Store.national options, member_key: **your-member-key**

Location

Access::Location.search options, member_key: **your-member-key**
Access::Location.find **location_key**, options, member_key: **your-member-key**

Category

Access::Category.search options, member_key: **your-member-key**
Access::Category.find **category_key**, options, member_key: **your-member-key**

Autocomplete

Access::Autocomplete.search options
Access::Autocomplete.search_stores options
Access::Autocomplete.search_categories options
Access::Autocomplete.search_offers options
Access::Autocomplete.search_locations options

Redeem

Access::Redeem.redeem_offer **key**, nil, options, member_key: **your-member-key**
Access::Redeem.redeem_offer **offer_key**, **redeem_type**, options, member_key: **your-member-key**

Member

City Savings

Access::CitySavings.search_city_savings options, member_key: **your-member-key**

Channel

Access::Channel.search options
Access::Channel.find **channel_key**, options

Campaign

Access::Campaign.search options
Access::Campaign.find **campaign_key**, options

Spot

Access::Spot.search_by_channel **channel_key**, options
Access::Spot.search_by_campaign **campaign_key**, options
Access::Spot.find **spot_key**, options

Internal Admin only Calls

Filter

Access::Filter.search options
Access::Filter.find **filter_key**, options

Report

Access::Report.all_usage options
Access::Report.usage options
Access::Report.usage_other **token**, options

Token

Access::Token.search options
Access::Token.find **token**, options

Oauth Application

Access::OauthApplication.search options
Access::OauthApplication.find **application_id**, options
Access::OauthApplication.search_tokens **application_id**, options
Access::OauthApplication.find_token **application_id**, **token_id**, options
Access::OauthApplication.create_token **application_id**, options
Access::OauthApplication.create **application_id**, options
Access::OauthApplication.update **application_id**, options
Access::OauthApplication.delete **application_id**, options

Verify

  Access::Verify.token options
  Access::Verify.filter options

AMT

Need amt permission scope for your application before you can access these api's

# pass in an array of members you want to import with the required parameters:
# https://docs.accessdevelopment.com/amt/importing-members.html#overview
members_array = [{organization_customer_identifier: 'example', program_customer_identifier: 'example', member_customer_identifier: 'example' }]
a = Access::Amt.import(members_array)
a = Access::Amt.list()

a = Access::Amt.show(import_id)


Contributing

  1. Fork it ( https://github.com/access-development/api-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Running the Tests

ACCESS_TOKEN=**your-access-token** rake

ACCESS_TOKEN=*your-access-token** guard

or add your environment variables to a .env file and run the test simply with rake or guard

Running the Gem in Console

ACCESS_TOKEN=*your-access-token** ruby bin/console

or add your environment variables to a .env file and run ruby bin/console