springboard-retail 4.0.1 → 4.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 749ec3a018626e45895cdf3ce674d69ac06803b2
4
- data.tar.gz: 8e779076c490e2d7d331b0488a8b7a28a054b843
3
+ metadata.gz: 738a7ddac21ce8cd9e2b2a74bd1fef9cddd504cc
4
+ data.tar.gz: b4b5290211fe0fe1c9fa7a5af94f233db8e01c79
5
5
  SHA512:
6
- metadata.gz: 6c96e952949e093a9703cce11b9db9e17662eae0f49fecb37775c680d15623760bc5e749f84a16e24bc0abec06e83967bda583ef4cfe341b042e9e4cc4633255
7
- data.tar.gz: edff0014f54cae6814448300aa2eb396f984e9140de482b35a09469cb76cb273da5b751258f33b81e1ec8a1750cab283a6b16b57a7d1d8550058a36ad422d635
6
+ metadata.gz: 7c5563eff3f6cfb9513ccc8559e043b50edf1ccd7b536b6c1e6effb0fbd4f090d194ba00a26a177e1cdfc49640a46a40c7f2c660c0ea2cc537a4ebc3a91295b7
7
+ data.tar.gz: f0d59e9cd2c1dc3a001d0254e8756a9eca0c30baf344a17bd23df9779dc05b3c6e715f1fadf2354fece490a892cc80e280345f1f157dc23eda636bc1fcc4904b
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  bundler_args: --without development
3
4
  rvm:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- springboard-retail (4.0.1)
4
+ springboard-retail (4.1.0)
5
5
  addressable (~> 2.2.8)
6
6
  hashie
7
7
  json (>= 1.7.4)
@@ -22,8 +22,8 @@ GEM
22
22
  safe_yaml (~> 1.0.0)
23
23
  diff-lcs (1.2.5)
24
24
  docile (1.1.5)
25
- hashie (3.4.1)
26
- json (1.8.2)
25
+ hashie (3.4.3)
26
+ json (1.8.3)
27
27
  method_source (0.8.2)
28
28
  mime-types (2.4.3)
29
29
  multi_json (1.11.0)
@@ -75,3 +75,6 @@ DEPENDENCIES
75
75
  rspec (~> 3.2)
76
76
  springboard-retail!
77
77
  webmock
78
+
79
+ BUNDLED WITH
80
+ 1.11.2
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/springboard-retail.png)](http://badge.fury.io/rb/springboard-retail)
4
4
  [![Build Status](https://travis-ci.org/springboardretail/springboard-client-ruby.png?branch=master)](https://travis-ci.org/springboardretail/springboard-client-ruby)
5
5
  [![Code Climate](https://codeclimate.com/github/springboardretail/springboard-client-ruby.png)](https://codeclimate.com/github/springboardretail/springboard-client-ruby)
6
- [![Coverage Status](https://coveralls.io/repos/springboardretail/springboard-client-ruby/badge.png)](https://coveralls.io/r/springboardretail/springboard-client-ruby)
6
+ [![Coverage Status](https://coveralls.io/repos/github/springboardretail/springboard-client-ruby/badge.svg?branch=master)](https://coveralls.io/github/springboardretail/springboard-client-ruby?branch=master)
7
7
  [![Dependency Status](https://gemnasium.com/springboardretail/springboard-client-ruby.png)](https://gemnasium.com/springboardretail/springboard-client-ruby)
8
8
 
9
9
  This is the [Springboard Retail](http://springboardretail.com/) (a point-of-sale/retail management system) client library for Ruby. It provides access to the Springboard Retail HTTP API.
@@ -27,8 +27,10 @@ gem install springboard-retail
27
27
 
28
28
  ```ruby
29
29
  require 'springboard-retail'
30
- springboard = Springboard::Client.new 'https://example.myspringboard.us/api'
31
- springboard.auth :username => 'user', :password => 'secret'
30
+ springboard = Springboard::Client.new(
31
+ 'https://example.myspringboard.us/api',
32
+ token: 'secret_token'
33
+ )
32
34
  ```
33
35
 
34
36
  ## Resource oriented
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
2
3
  Bundler.require(:default, :development)
3
4
 
4
5
  require 'rspec/core/rake_task'
@@ -42,6 +42,7 @@ module Springboard
42
42
  # @param [String] base_uri Base URI
43
43
  # @option opts [Boolean, String] :debug Pass true to debug to stdout. Pass a String to debug to given filename.
44
44
  # @option opts [Boolean] :insecure Disable SSL certificate verification
45
+ # @option opts [String] :token Springboard API Token
45
46
  def initialize(base_uri, opts={})
46
47
  @base_uri = URI.parse(base_uri)
47
48
  configure_session(base_uri, opts)
@@ -69,6 +70,7 @@ module Springboard
69
70
  end
70
71
 
71
72
  ##
73
+ # @deprecated see {#initialize}.
72
74
  # Passes the given credentials to the server, storing the session token on success.
73
75
  #
74
76
  # @raise [AuthFailed] If the credentials were invalid or the server returned an error
@@ -78,6 +80,8 @@ module Springboard
78
80
  # @option opts [String] :username Springboard username
79
81
  # @option opts [String] :password Springboard password
80
82
  def auth(opts={})
83
+ warn "[DEPRECATION] `auth` is deprecated. Please use `Springboard::Client.new '#{base_uri}', token: 'secret_token'` instead."
84
+
81
85
  unless opts[:username] && opts[:password]
82
86
  raise "Must specify :username and :password"
83
87
  end
@@ -199,7 +203,7 @@ module Springboard
199
203
  end
200
204
  end
201
205
  end
202
-
206
+
203
207
  ##
204
208
  # Returns a count of subordinate resources of the given collection resource
205
209
  # URI.
@@ -248,6 +252,7 @@ module Springboard
248
252
  def configure_session(base_url, opts)
249
253
  session.base_url = base_url
250
254
  session.headers['Content-Type'] = 'application/json'
255
+ session.headers['Authorization'] = "Bearer #{opts[:token]}" if opts[:token]
251
256
  session.handle_cookies
252
257
  session.insecure = opts[:insecure] if opts.has_key?(:insecure)
253
258
  session.timeout = DEFAULT_TIMEOUT
@@ -6,10 +6,6 @@ describe Springboard::Client::Resource do
6
6
  let(:resource_path) { '/some/path' }
7
7
  let(:resource) { Springboard::Client::Resource.new(client, resource_path) }
8
8
 
9
- def parse_uri(uri)
10
- Addressable::URI.parse(uri)
11
- end
12
-
13
9
  describe "[]" do
14
10
  it "should return a new resource" do
15
11
  expect(resource["subpath"]).to be_a Springboard::Client::Resource
@@ -68,6 +68,19 @@ describe Springboard::Client do
68
68
  client.__send__(:configure_session, base_url, {})
69
69
  expect(client.session.connect_timeout).to eq(Springboard::Client::DEFAULT_CONNECT_TIMEOUT)
70
70
  end
71
+
72
+ context 'headers' do
73
+ let(:headers) { double('headers') }
74
+ before do
75
+ allow(session).to receive(:headers).and_return(headers)
76
+ end
77
+
78
+ it 'sets Content-Type header' do
79
+ expect(headers).to receive(:[]=).once.with('Content-Type', 'application/json')
80
+ expect(headers).to receive(:[]=).once.with('Authorization', 'Bearer token')
81
+ client.__send__(:configure_session, base_url, :token => 'token')
82
+ end
83
+ end
71
84
  end
72
85
 
73
86
  describe "[]" do
@@ -76,6 +89,21 @@ describe Springboard::Client do
76
89
  end
77
90
  end
78
91
 
92
+ describe "debug=" do
93
+ context "with a file path" do
94
+ it "should pass the path to enable_debug on the Patron session" do
95
+ expect(client.session).to receive(:enable_debug).with('/path/to/log')
96
+ client.debug = '/path/to/log'
97
+ end
98
+ end
99
+
100
+ context "with true" do
101
+ it "should pass nil to enable_debug on the Patron session" do
102
+ expect(client.session).to receive(:enable_debug).with(nil)
103
+ client.debug = true
104
+ end
105
+ end
106
+ end
79
107
 
80
108
  [:get, :head, :delete].each do |method|
81
109
  bang_method = "#{method}!"
@@ -211,4 +239,14 @@ describe Springboard::Client do
211
239
  end.to yield_successive_args(*all_results)
212
240
  end
213
241
  end
242
+
243
+ describe "count" do
244
+ it "should request the first page/record of the collection and return the total" do
245
+ response = double(Springboard::Client::Response)
246
+ allow(response).to receive(:[]).with('total').and_return(17)
247
+ expect(client).to receive(:get!).with("/things?page=1&per_page=1".to_uri)
248
+ .and_return(response)
249
+ expect(client.count('/things')).to eq(17)
250
+ end
251
+ end
214
252
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'springboard-retail'
3
- s.version = '4.0.1'
3
+ s.version = '4.1.0'
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.authors = ['Jay Stotz']
6
6
  s.summary = 'Springboard Retail API client library'
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: springboard-retail
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Stotz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-08 00:00:00.000000000 Z
11
+ date: 2016-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: patron
@@ -103,8 +103,8 @@ files:
103
103
  - vendor/cache/crack-0.4.2.gem
104
104
  - vendor/cache/diff-lcs-1.2.5.gem
105
105
  - vendor/cache/docile-1.1.5.gem
106
- - vendor/cache/hashie-3.4.1.gem
107
- - vendor/cache/json-1.8.2.gem
106
+ - vendor/cache/hashie-3.4.3.gem
107
+ - vendor/cache/json-1.8.3.gem
108
108
  - vendor/cache/method_source-0.8.2.gem
109
109
  - vendor/cache/mime-types-2.4.3.gem
110
110
  - vendor/cache/multi_json-1.11.0.gem
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: 1.3.6
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.2.2
148
+ rubygems_version: 2.4.8
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Springboard Retail API client library
Binary file
Binary file