sterling 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.
@@ -0,0 +1,11 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'sterling'
5
+
6
+ RSpec.configure do |config|
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ config.run_all_when_everything_filtered = true
9
+ config.filter_run :focus
10
+ config.order = 'random'
11
+ end
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+ require 'vcr_helper'
3
+
4
+ describe Sterling::API::Client do
5
+
6
+ context 'valid config' do
7
+ before do
8
+ Sterling.configure do |config|
9
+ config.api_version = '2.1'
10
+ config.api_key = '1234'
11
+ config.retailer_id = 'test'
12
+ config.api_host = 'api'
13
+ end
14
+ end
15
+
16
+ it 'sets the base url properly' do
17
+ expect(Sterling::API::Client.new.base_url).to eql("api.retailigence.com/v2.1/")
18
+ end
19
+ end
20
+
21
+ context '.products' do
22
+ before do
23
+ Sterling.configure do |config|
24
+ config.api_version = '2.1'
25
+ config.api_key = 'dVrbDdN_3tqdUot_sgLn6tY1p4HIp0kK'
26
+ config.retailer_id = 'test'
27
+ config.api_host = 'api'
28
+ end
29
+
30
+ @api = Sterling::API::Client.new
31
+ end
32
+
33
+ it 'queries posts properly' do
34
+ VCR.use_cassette('products') do
35
+ products = @api.products('75033', 'Baby Bottle')
36
+ expect(products.class).to eql(Array)
37
+ expect(products.first.class).to eql(Sterling::API::Product)
38
+ product = products.first
39
+
40
+ expect(product.product).to_not be_nil
41
+ expect(product.location).to_not be_nil
42
+ expect(product.distance).to_not be_nil
43
+ expect(product.price).to_not be_nil
44
+ expect(product.currency).to_not be_nil
45
+ expect(product.inventory).to_not be_nil
46
+ end
47
+ end
48
+ end
49
+
50
+ context 'invalid config' do
51
+ it 'raises an error if the api version is nil' do
52
+ Sterling.configure do |config|
53
+ config.api_version = nil
54
+ config.api_key = '1234'
55
+ config.retailer_id = 'test'
56
+ config.api_host = 'api'
57
+ end
58
+
59
+ expect{Sterling::API::Client.new}.to raise_error
60
+ end
61
+
62
+ it 'raises an error if the api version is not valid' do
63
+ Sterling.configure do |config|
64
+ config.api_version = '4.0'
65
+ config.api_key = '1234'
66
+ config.retailer_id = 'test'
67
+ config.api_host = 'api'
68
+ end
69
+
70
+ expect{Sterling::API::Client.new}.to raise_error
71
+ end
72
+
73
+ it 'raises an error if the retailer is nil' do
74
+ Sterling.configure do |config|
75
+ config.api_version = '2.1'
76
+ config.api_key = '1234'
77
+ config.retailer_id = nil
78
+ config.api_host = 'api'
79
+ end
80
+
81
+ expect{Sterling::API::Client.new}.to raise_error
82
+ end
83
+
84
+ it 'raises an error if the host is nil' do
85
+ Sterling.configure do |config|
86
+ config.api_version = '2.1'
87
+ config.api_key = '1234'
88
+ config.retailer_id = 'test'
89
+ config.api_host = nil
90
+ end
91
+
92
+ expect{Sterling::API::Client.new}.to raise_error
93
+ end
94
+ it 'raises an error if the api host is invalid' do
95
+ Sterling.configure do |config|
96
+ config.api_version = '2.1'
97
+ config.api_key = '1234'
98
+ config.retailer_id = 'test'
99
+ config.api_host = 'api_broken'
100
+ end
101
+
102
+ expect{Sterling::API::Client.new}.to raise_error
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sterling do
4
+
5
+ it 'can set the API Version' do
6
+ Sterling.configure do |config|
7
+ config.api_version = '1'
8
+ end
9
+
10
+ expect(Sterling.configuration.api_version).to eql('1')
11
+ end
12
+
13
+ it 'can set the API Key' do
14
+ Sterling.configure do |config|
15
+ config.api_key = 'abcd'
16
+ end
17
+
18
+ expect(Sterling.configuration.api_key).to eql('abcd')
19
+ end
20
+
21
+ it 'can set the Retailer ID' do
22
+ Sterling.configure do |config|
23
+ config.retailer_id = '12345'
24
+ end
25
+ expect(Sterling.configuration.retailer_id).to eql('12345')
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sterling do
4
+ it 'has a version' do
5
+ expect(Sterling::VERSION).to_not be_nil
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ require 'vcr'
2
+ VCR.configure do |c|
3
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
4
+ c.hook_into :webmock # or :fakeweb
5
+ end
@@ -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 'sterling/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sterling"
8
+ spec.version = Sterling::VERSION
9
+ spec.authors = ["Bryan Mikaelian"]
10
+ spec.email = ["bryan@puhsh.com"]
11
+ spec.summary = %q{An API wrapper for the Retailigence API}
12
+ spec.description = %q{This is a ruby gem that can be used to interact with the Retailigence API. The responses are nicely formatted into a simple Hash that lets you work with the response quite nicely..}
13
+ spec.homepage = "http://developer.puhsh.com"
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.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency 'rspec', '~> 2.14.1'
24
+ spec.add_development_dependency 'vcr', '~> 2.8.0'
25
+ spec.add_development_dependency 'webmock'
26
+
27
+ spec.add_dependency 'activesupport', '~> 3.2.17'
28
+ spec.add_dependency 'faraday', '0.9.0'
29
+ spec.add_dependency 'crack', '~> 0.4.1'
30
+ end
metadata ADDED
@@ -0,0 +1,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sterling
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Bryan Mikaelian
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-28 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.14.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.14.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.8.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.8.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: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.2.17
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.2.17
97
+ - !ruby/object:Gem::Dependency
98
+ name: faraday
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.9.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.9.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: crack
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.4.1
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.4.1
125
+ description: This is a ruby gem that can be used to interact with the Retailigence
126
+ API. The responses are nicely formatted into a simple Hash that lets you work with
127
+ the response quite nicely..
128
+ email:
129
+ - bryan@puhsh.com
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - ".gitignore"
135
+ - Gemfile
136
+ - LICENSE.txt
137
+ - README.md
138
+ - Rakefile
139
+ - lib/sterling.rb
140
+ - lib/sterling/api/client.rb
141
+ - lib/sterling/api/product.rb
142
+ - lib/sterling/configuration.rb
143
+ - lib/sterling/error.rb
144
+ - lib/sterling/version.rb
145
+ - spec/fixtures/vcr_cassettes/products.yml
146
+ - spec/spec_helper.rb
147
+ - spec/sterling/api/client_spec.rb
148
+ - spec/sterling/configuration_spec.rb
149
+ - spec/sterling/version_spec.rb
150
+ - spec/vcr_helper.rb
151
+ - sterling.gemspec
152
+ homepage: http://developer.puhsh.com
153
+ licenses:
154
+ - MIT
155
+ metadata: {}
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubyforge_project:
172
+ rubygems_version: 2.2.2
173
+ signing_key:
174
+ specification_version: 4
175
+ summary: An API wrapper for the Retailigence API
176
+ test_files:
177
+ - spec/fixtures/vcr_cassettes/products.yml
178
+ - spec/spec_helper.rb
179
+ - spec/sterling/api/client_spec.rb
180
+ - spec/sterling/configuration_spec.rb
181
+ - spec/sterling/version_spec.rb
182
+ - spec/vcr_helper.rb