access 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ae88dc0242b7774cc1ff3b22b877a0b68147dc4f
4
+ data.tar.gz: 39b05913c4dd0cff112e77f47ec5bf7525e09098
5
+ SHA512:
6
+ metadata.gz: 2e216748c7697762c007f023c638afe459f4d6510811dc0b5d903b114a331032812f31dce4e3a5e95dfc659114bb54a6bdc2a31fa1f40c2550342ae02c614d65
7
+ data.tar.gz: 54b0590f1b016fb7254f24aedef1610259e24b7c283298610c07a0debaf5df52e2f4d0dd3423a531d57eb8cdfaa4e024ccfa3c7516aa5279f2d21d80a0de2c6e
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ api-ruby
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in access.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ben Eggett
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,97 @@
1
+ [![Build Status](https://magnum.travis-ci.com/access-development/api-ruby.svg?token=T9pynazhFyqzCqj2LUNj&branch=master)](https://magnum.travis-ci.com/access-development/api-ruby) [![Code Climate](https://codeclimate.com/repos/5466a5ce69568076f20003de/badges/9bf8e7713208de5ce932/gpa.svg)](https://codeclimate.com/repos/5466a5ce69568076f20003de/feed)
2
+
3
+ # Access API
4
+
5
+ A ruby wrapper for the Access API
6
+
7
+ ## Installation
8
+
9
+ ```ruby
10
+ gem 'access', path: '../api-ruby'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install access
20
+
21
+ ## Setup
22
+
23
+ ###Config setup
24
+
25
+ You can configure the following options:
26
+
27
+ - `access_token` Required
28
+ - `format` Set as "json" or "xml". Default is "json"
29
+ - `api_environment` Set as "staging" or "production". Default is "staging"
30
+ - `api_version` "v1" is default.
31
+ - `hashify` Returns the results all using Hashie::Mash if "true", Default is "false"
32
+
33
+ You can set these buy creating environment variables called:
34
+
35
+ `ENV['ACCESS_TOKEN']`, `ENV['ACCESS_FORMAT']`, `ENV['ACCESS_ENVIRONMENT']`, `ENV['ACCESS_VERSION']`, `ENV['ACCESS_HASHIFY']`
36
+
37
+ or create an initializer file and set your config
38
+
39
+ ```
40
+ Access.configure do |config|
41
+ config.access_token = ENV['ACCESS_TOKEN']
42
+ config.hashify = "true"
43
+ end
44
+ ```
45
+
46
+ You can also set them one at a time
47
+
48
+ `Access.config.format = 'xml`
49
+
50
+ ###Making Calls
51
+
52
+ ####Offer
53
+
54
+ `Access::Offer.search options`
55
+ `Access::Offer.find offer_key options` *member_key required*
56
+
57
+ ####Store
58
+
59
+ `Access::Store.search options`
60
+ `Access::Store.find store_key options`
61
+
62
+ ####Location
63
+
64
+ `Access::Location.search options`
65
+ `Access::Location.find location_key options`
66
+
67
+ ####Category
68
+
69
+ `Access::Category.search options`
70
+ `Access::Category.find key options`
71
+
72
+ ####Report
73
+
74
+ `Access::Report.usage options`
75
+ `Access::Report.usage token options`
76
+
77
+ ####Token
78
+
79
+ `Access::Token.verify options`
80
+ `Access::Token.verify_other token options`
81
+
82
+ ####Redeem
83
+
84
+ `Access::Redeem.redeem_offer key nil options` *member_key required*
85
+ `Access::Redeem.redeem_offer key redeem_type options` *member_key required*
86
+
87
+ ####Member
88
+
89
+
90
+ ## Contributing
91
+
92
+ 1. Fork it ( https://github.com/access-development/api-ruby/fork )
93
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
94
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
95
+ 4. Push to the branch (`git push origin my-new-feature`)
96
+ 5. Create a new Pull Request
97
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/access.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'access/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "access"
8
+ spec.version = Access::VERSION
9
+ spec.authors = ["Ben Eggett"]
10
+ spec.email = ["beneggett@gmail.com"]
11
+ spec.summary = %q{Ruby wrapper for Access API}
12
+ spec.description = %q{Ruby wrapper for Access API}
13
+ spec.homepage = "http://www.github.com/access-development/api-ruby"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest"
24
+ spec.add_development_dependency "vcr"
25
+ spec.add_development_dependency "webmock"
26
+ spec.add_development_dependency "pry"
27
+
28
+ spec.add_dependency "httparty", "~> 0.8.0"
29
+ spec.add_dependency "hashie", "~> 2.0"
30
+ end
data/lib/access.rb ADDED
@@ -0,0 +1,23 @@
1
+ require "rubygems"
2
+ require "hashie"
3
+ require "httparty"
4
+
5
+ require "access/version"
6
+ # require "access/error"
7
+ require "access/config"
8
+ require "access/request"
9
+ require "access/api"
10
+ require "access/offer"
11
+ require "access/store"
12
+ require "access/location"
13
+ require "access/category"
14
+ require "access/report"
15
+ require "access/token"
16
+ require "access/redeem"
17
+ # require "access/member"
18
+
19
+ HTTParty::Response.class_eval do
20
+ def hashify
21
+ Hashie::Mash.new self
22
+ end
23
+ end
data/lib/access/api.rb ADDED
@@ -0,0 +1,63 @@
1
+ module Access
2
+ class Api < Request
3
+
4
+ ###offer
5
+ def search_categories(options = {})
6
+ get("/categories", "offer", options)
7
+ end
8
+
9
+ def find_category(category_id, options = {})
10
+ get("/categories/#{category_id}", "offer", options)
11
+ end
12
+
13
+ def search_offers(options={})
14
+ get("/offers", "offer", options)
15
+ end
16
+
17
+ def find_offer(offer_id, options = {})
18
+ get("/offers/#{offer_id}", "offer", options)
19
+ end
20
+
21
+ def search_locations(options={})
22
+ get("/locations", "offer", options)
23
+ end
24
+
25
+ def find_location(location_id, options = {})
26
+ get("/locations/#{location_id}", "offer", options)
27
+ end
28
+
29
+ def search_stores(options={})
30
+ get("/stores", "offer", options)
31
+ end
32
+
33
+ def find_store(store_id, options = {})
34
+ get("/stores/#{store_id}", "offer", options)
35
+ end
36
+
37
+ ###token
38
+ def verify(options = {})
39
+ get("/verify", "token", options)
40
+ end
41
+
42
+ def verify_other(token, options = {})
43
+ get("/verify/#{token}", "token", options)
44
+ end
45
+
46
+ ###redeem
47
+ def redeem_offer(offer_key, redeem_type = nil, options = {})
48
+ get("/redeem/#{offer_key}/#{redeem_type}", "redeem", options)
49
+ end
50
+
51
+ ###report
52
+ def usage(options = {})
53
+ get("/usage", "report", options)
54
+ end
55
+
56
+ def usage_other(token, options = {})
57
+ get("/usage/#{token}", "report", options)
58
+ end
59
+
60
+ ###member
61
+
62
+ end
63
+ end
@@ -0,0 +1,11 @@
1
+ module Access
2
+ class Category
3
+ def self.search(options = {})
4
+ Access::Api.new.search_categories options
5
+ end
6
+
7
+ def self.find(key, options = {})
8
+ Access::Api.new.find_category key, options
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ module Access
2
+ class << self
3
+ attr_accessor :config
4
+ end
5
+
6
+ def self.config
7
+ @config && @config.access_token ? @config : @config = Config.new
8
+ end
9
+
10
+ # Set options via block
11
+ def self.configure
12
+ yield(config) if block_given?
13
+ end
14
+
15
+ class Config
16
+ attr_accessor :access_token, :format, :api_environment, :api_version, :hashify
17
+
18
+ def initialize
19
+ @access_token = ENV['ACCESS_TOKEN']
20
+ @format = ENV['ACCESS_FORMAT'] || 'json'
21
+ @api_environment = ENV['ACCESS_ENVIRONMENT'] || 'staging'
22
+ @api_version = ENV['ACCESS_VERSION'] || 'v1'
23
+ @hashify = ENV['ACCESS_HASHIFY'] || 'false'
24
+ end
25
+
26
+ def reset
27
+ self.access_token = ENV['ACCESS_TOKEN']
28
+ self.format = 'json'
29
+ self.api_environment = 'staging'
30
+ self.api_version = 'v1'
31
+ self.hashify = false
32
+ end
33
+ end
34
+ end
35
+
@@ -0,0 +1,11 @@
1
+ module Access
2
+ class Location
3
+ def self.search(options = {})
4
+ Access::Api.new.search_locations options
5
+ end
6
+
7
+ def self.find(key, options = {})
8
+ Access::Api.new.find_location key, options
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module Access
2
+ class Member
3
+
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ module Access
2
+ class Offer
3
+ def self.search(options = {})
4
+ Access::Api.new.search_offers options
5
+ end
6
+
7
+ def self.find(key, options = {})
8
+ Access::Api.new.find_offer key, options
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Access
2
+ class Redeem
3
+ def self.redeem_offer(key, redeem_type = nil, options = {})
4
+ Access::Api.new.redeem_offer key, redeem_type, options
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module Access
2
+ class Report
3
+ def self.usage(options = {})
4
+ Access::Api.new.usage options
5
+ end
6
+
7
+ def self.usage_other(key, options = {})
8
+ Access::Api.new.usage_other key, options
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ module Access
2
+ class Request
3
+ include HTTParty
4
+
5
+ def get(path, api_type, options={})
6
+ set_format
7
+ results = self.class.get(set_base(api_type) + path, headers: headers, query: options)
8
+ Access.config.hashify == "true" ? results.hashify : results
9
+ end
10
+
11
+ private
12
+
13
+ def set_base(api_type)
14
+ if Access.config.api_environment == 'production'
15
+ "https://#{api_type}.adcrws.com/#{Access.config.api_version}"
16
+ else
17
+ "https://#{api_type}-demo.adcrws.com/#{Access.config.api_version}"
18
+ end
19
+ end
20
+
21
+ def set_format
22
+ self.class.format Access.config.format.to_sym
23
+ end
24
+
25
+ def headers
26
+ {"Access-Token" => Access.config.access_token}
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ module Access
2
+ class Store
3
+ def self.search(options = {})
4
+ Access::Api.new.search_stores options
5
+ end
6
+
7
+ def self.find(key, options = {})
8
+ Access::Api.new.find_store key, options
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Access
2
+ class Token
3
+ def self.verify(options = {})
4
+ Access::Api.new.verify options
5
+ end
6
+
7
+ def self.verify_other(token, options = {})
8
+ Access::Api.new.verify_other token, options
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ module Access
2
+ VERSION = "1.0.0"
3
+ end
4
+
@@ -0,0 +1,5 @@
1
+ require './test/test_helper'
2
+
3
+ class AccessOfferTest < Minitest::Test
4
+
5
+ end
@@ -0,0 +1,9 @@
1
+ require './lib/access'
2
+ require 'minitest/autorun'
3
+ require 'webmock/minitest'
4
+ require 'vcr'
5
+
6
+ VCR.configure do |c|
7
+ c.cassette_library_dir = "test/fixtures"
8
+ c.hook_into :webmock
9
+ end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: access
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Eggett
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: httparty
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.8.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.8.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: hashie
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.0'
125
+ description: Ruby wrapper for Access API
126
+ email:
127
+ - beneggett@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".ruby-gemset"
134
+ - ".ruby-version"
135
+ - Gemfile
136
+ - LICENSE.txt
137
+ - README.md
138
+ - Rakefile
139
+ - access.gemspec
140
+ - lib/access.rb
141
+ - lib/access/api.rb
142
+ - lib/access/category.rb
143
+ - lib/access/config.rb
144
+ - lib/access/location.rb
145
+ - lib/access/member.rb
146
+ - lib/access/offer.rb
147
+ - lib/access/redeem.rb
148
+ - lib/access/report.rb
149
+ - lib/access/request.rb
150
+ - lib/access/store.rb
151
+ - lib/access/token.rb
152
+ - lib/access/version.rb
153
+ - test/offers/offer_test.rb
154
+ - test/test_helper.rb
155
+ homepage: http://www.github.com/access-development/api-ruby
156
+ licenses:
157
+ - MIT
158
+ metadata: {}
159
+ post_install_message:
160
+ rdoc_options: []
161
+ require_paths:
162
+ - lib
163
+ required_ruby_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ required_rubygems_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ requirements: []
174
+ rubyforge_project:
175
+ rubygems_version: 2.4.3
176
+ signing_key:
177
+ specification_version: 4
178
+ summary: Ruby wrapper for Access API
179
+ test_files:
180
+ - test/offers/offer_test.rb
181
+ - test/test_helper.rb