gun_broker 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f1909c07880bf70fd3f4c385c456168ae2409e5
4
- data.tar.gz: c11c711ae5950ba9d3c7a3cb18618d3dde0977ea
3
+ metadata.gz: 263f58913c30a8bc6cd92e93f7639764e36d5419
4
+ data.tar.gz: b81f8988a611e475e3d0c2c5dba5ab27f2d77493
5
5
  SHA512:
6
- metadata.gz: 49b71a28c539403d802d1be79ae5960bb41cfec1a6e8c8e980e75785686221b3722a4bca874d90fea7fdb74ba7e9657b4504bfd938ccfadf21cb5604d579f9b2
7
- data.tar.gz: 4cc1b3c0eedf8b3cc18d0e00aa7951a5e6401f1d0b176d80f54174b575d69b57efcbd5060c2f20be6e0018e35de9649b4de6dd97604e1316fbf61d68afab3106
6
+ metadata.gz: 75d66025a4a1678065a866fd879edb113b5662a4fe02f99dbfa7cc13d41b4149397ca8f0e56721497a4b7e2625a72c9b7f776e59e33d64e0d77b03c60d888ce6
7
+ data.tar.gz: 7e3283d6755afd90d704bdbd502e495e9b00458875c4d4b2b6517de0197b43de23bcf02c62057a6ea243524452d11374bfa4591d8c78c94062cf421e0e8cecf1
data/README.md CHANGED
@@ -50,8 +50,16 @@ return an array of `GunBroker::Item` instances.
50
50
 
51
51
  ```ruby
52
52
  user.items # => [GunBroker::Item, ...]
53
- user.unsold_items # => [GunBroker::Item, ...]
54
- user.sold_items # => [GunBroker::Item, ...]
53
+ user.items_unsold # => [GunBroker::Item, ...]
54
+ user.items_sold # => [GunBroker::Item, ...]
55
+ ```
56
+
57
+ To revoke the access token, call `User#deauthenticate!`. This method is also aliased as `#revoke_access_token!`.
58
+
59
+ ```ruby
60
+ user.token # => 'user-access-token'
61
+ user.deauthenticate!
62
+ user.token # => nil
55
63
  ```
56
64
 
57
65
  ### GunBroker::Item
@@ -21,18 +21,19 @@ module GunBroker
21
21
  @token = nil
22
22
  true # Explicit `true` so this method won't return the `nil` set above.
23
23
  end
24
+ alias_method :revoke_access_token!, :deauthenticate!
24
25
 
25
26
  def items
26
27
  response = GunBroker::API.get('/Items', { 'SellerName' => @username }, { 'X-AccessToken' => @token })
27
28
  response['results'].map { |result| GunBroker::Item.new(result) }
28
29
  end
29
30
 
30
- def unsold_items
31
+ def items_unsold
31
32
  response = GunBroker::API.get('/ItemsUnsold', {}, { 'X-AccessToken' => @token })
32
33
  response['results'].map { |result| GunBroker::Item.new(result) }
33
34
  end
34
35
 
35
- def sold_items
36
+ def items_sold
36
37
  response = GunBroker::API.get('/ItemsSold', {}, { 'X-AccessToken' => @token })
37
38
  response['results'].map { |result| GunBroker::Item.new(result) }
38
39
  end
@@ -1,3 +1,3 @@
1
1
  module GunBroker
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -83,6 +83,17 @@ describe GunBroker::User do
83
83
  expect { user.deauthenticate! }.to raise_error(GunBroker::Error::NotAuthorized)
84
84
  end
85
85
  end
86
+
87
+ it 'should have a #revoke_access_token! alias' do
88
+ user = GunBroker::User.new(username, token: token)
89
+
90
+ stub_request(:delete, endpoint)
91
+ .with(headers: headers)
92
+ .to_return(body: response_fixture('deauthenticate'))
93
+
94
+ expect(user.revoke_access_token!).to eq(true)
95
+ expect(user.token).to be_nil
96
+ end
86
97
  end
87
98
 
88
99
  context '#items' do
@@ -118,7 +129,7 @@ describe GunBroker::User do
118
129
  end
119
130
  end
120
131
 
121
- context '#unsold_items' do
132
+ context '#items_unsold' do
122
133
  let(:endpoint) { [GunBroker::API::GUNBROKER_API, '/ItemsUnsold'].join }
123
134
 
124
135
  context 'on success' do
@@ -128,8 +139,8 @@ describe GunBroker::User do
128
139
  .to_return(body: response_fixture('items'))
129
140
 
130
141
  user = GunBroker::User.new(username, token: token)
131
- expect(user.unsold_items).not_to be_empty
132
- expect(user.unsold_items.first).to be_a(GunBroker::Item)
142
+ expect(user.items_unsold).not_to be_empty
143
+ expect(user.items_unsold.first).to be_a(GunBroker::Item)
133
144
  end
134
145
  end
135
146
 
@@ -140,12 +151,12 @@ describe GunBroker::User do
140
151
  .to_return(body: response_fixture('not_authorized'), status: 401)
141
152
 
142
153
  user = GunBroker::User.new(username, token: token)
143
- expect { user.unsold_items }.to raise_error(GunBroker::Error::NotAuthorized)
154
+ expect { user.items_unsold }.to raise_error(GunBroker::Error::NotAuthorized)
144
155
  end
145
156
  end
146
157
  end
147
158
 
148
- context '#sold_items' do
159
+ context '#items_sold' do
149
160
  let(:endpoint) { [GunBroker::API::GUNBROKER_API, '/ItemsSold'].join }
150
161
 
151
162
  context 'on success' do
@@ -155,8 +166,8 @@ describe GunBroker::User do
155
166
  .to_return(body: response_fixture('items'))
156
167
 
157
168
  user = GunBroker::User.new(username, token: token)
158
- expect(user.sold_items).not_to be_empty
159
- expect(user.sold_items.first).to be_a(GunBroker::Item)
169
+ expect(user.items_sold).not_to be_empty
170
+ expect(user.items_sold.first).to be_a(GunBroker::Item)
160
171
  end
161
172
  end
162
173
 
@@ -167,7 +178,7 @@ describe GunBroker::User do
167
178
  .to_return(body: response_fixture('not_authorized'), status: 401)
168
179
 
169
180
  user = GunBroker::User.new(username, token: token)
170
- expect { user.sold_items }.to raise_error(GunBroker::Error::NotAuthorized)
181
+ expect { user.items_sold }.to raise_error(GunBroker::Error::NotAuthorized)
171
182
  end
172
183
  end
173
184
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gun_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Campbell