gyft 1.0.0 → 1.0.1

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: 1cacc42d597e9d65aaef5cb8fc4b4a1b1bd4d257
4
- data.tar.gz: 7d0bfd2bb5bcedcfb091c556eb17d9da29ac0d09
3
+ metadata.gz: ee03ef5abdae355a5a55b541b832c113d073fdad
4
+ data.tar.gz: efe4359388cad2c6790a963d829d4c5bb7e99946
5
5
  SHA512:
6
- metadata.gz: 2b05032d9ff5336b23772d406e72fb42270acca69212b69398adee074233ce401afe59cf74c9f8b4e4dffe328b9aea0e6b47e17284b289f1b597a53a5fa0c927
7
- data.tar.gz: 6922c59dcdeb5780b396937b7b9c37d45746adb7dd575009f92d73abce0f4a63c942df2b913efb4a83e94ccda5245602239bc35dd19f9c6db606c35f9c12a822
6
+ metadata.gz: 7c17a8f7263b7ecd1ab0a0f59a36a600a8e63e37bd63bd9f5844e6d14ceb86834c362a486a43ce9f9f1eda197d8c865b2f78f85849f3812447f2021fdc286b63
7
+ data.tar.gz: 28eaa9153cf168f5ab795f91104022ef8007e6257459c0af4ffa8dc6135f44389f46afa3595968c71946992fbeee90b54bfb3569e22b92bdd4b4849b47b057e1
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/gyft.svg)](https://badge.fury.io/rb/gyft) [![Build Status](https://travis-ci.org/cbetta/gyft.svg?branch=master)](https://travis-ci.org/cbetta/gyft)
4
4
 
5
- A wrapper for the [Gyft API](http://developer.gyft.com). Specification as per the [developer documentation](http://developer.gyft.com/io-docs).
5
+ A wrapper for the [Gyft API](http://developer.gyft.com). Specification is as described in the the [developer documentation](http://developer.gyft.com/io-docs).
6
6
 
7
7
  ## Installation
8
8
 
@@ -15,7 +15,7 @@ gem 'gyft'
15
15
  ## Getting started
16
16
 
17
17
  The client will accept the API key and secret either as parameters on initialization,
18
- or as environment variables. Additionally an `environment` can be set to either
18
+ or as environment variables. Additionally an `environment` parameter can be set to either
19
19
  `sandbox` (default) or `production`.
20
20
 
21
21
  ```rb
@@ -24,17 +24,15 @@ require 'gyft'
24
24
  # using parameters
25
25
  client = Gyft::Client.new(api_key: '...', api_secret: '...', environment: 'production')
26
26
 
27
- # using these environment variables are set:
27
+ # using environment variables:
28
28
  # * GYFT_RESELLER_API_KEY
29
29
  # * GYFT_RESELLER_API_SECRET
30
30
  # * GYFT_RESELLER_API_ENVIRONMENT
31
31
  client = Gyft::Client.new
32
-
33
- # now you are ready for your first API call
34
- client.reseller.shop_cards # => [#<Gyft::Card id=123, merchant_id="123", ...>, ...]
35
32
  ```
36
33
 
37
- The client provides with direct access to every API call as documented in the developer documentation. Additionally it also provides some convenience methods.
34
+ The client provides with direct access to every API call as documented in the
35
+ developer documentation. Additionally it also provides some convenience methods.
38
36
 
39
37
  ```rb
40
38
  # get a card to purchase
@@ -51,25 +49,28 @@ transaction.refund
51
49
 
52
50
  ### `client.cards`
53
51
 
54
- Maps to `client.reseller.shop_cards`, allows for easier access and a less verbose DSL.
52
+ Maps to `client.reseller.shop_cards`, allows for easier access and a less
53
+ verbose DSL.
55
54
 
56
55
  ### `card.purchase`
57
56
 
58
- Maps to `client.partner.purchase.gift_card_direct` and passes along all the same parameters while automatically setting the `shop_card_id`.
57
+ Maps to `client.partner.purchase.gift_card_direct` and passes along all the
58
+ same parameters while automatically setting the `shop_card_id`.
59
59
 
60
60
  ### `transaction.reload`
61
61
 
62
- The purchase method returns an incomplete transaction object. This convenience methods
63
- calls `client.reseller.transaction.find` passing along the transaction `id` and returns a
64
- new `Gyft::Transaction` object.
62
+ The purchase method returns an incomplete transaction object. This convenience
63
+ methods calls `client.reseller.transaction.find` passing along the transaction
64
+ `id` and returning a new `Gyft::Transaction` object.
65
65
 
66
66
  ### `transaction.refund`
67
67
 
68
- Maps to `client.reseller.transactions.refund` and automatically passes along the transaction `id`.
68
+ Maps to `client.reseller.transactions.refund` and automatically passes along
69
+ the transaction `id`.
69
70
 
70
71
  ## API
71
72
 
72
- ### GET /health/check
73
+ ### `GET /health/check`
73
74
 
74
75
  ```rb
75
76
  # with a connection
@@ -81,7 +82,7 @@ true
81
82
  false
82
83
  ```
83
84
 
84
- ### GET /reseller/shop_cards
85
+ ### `GET /reseller/shop_cards`
85
86
 
86
87
  Returns the shop cards available for purchase.
87
88
 
@@ -102,7 +103,7 @@ Gyft::Card {
102
103
  }
103
104
  ```
104
105
 
105
- ### GET /reseller/categories
106
+ ### `GET /reseller/categories`
106
107
 
107
108
  Returns all of the categories.
108
109
 
@@ -116,7 +117,7 @@ Gyft::Category {
116
117
  }
117
118
  ```
118
119
 
119
- ### GET /reseller/merchants
120
+ ### `GET /reseller/merchants`
120
121
 
121
122
  Returns all of the merchants.
122
123
 
@@ -169,7 +170,7 @@ Gyft::Merchant {
169
170
  }
170
171
  ```
171
172
 
172
- ### GET /reseller/account
173
+ ### `GET /reseller/account`
173
174
 
174
175
  Returns details of the reseller's account.
175
176
 
@@ -189,7 +190,7 @@ Gyft::Account {
189
190
  }
190
191
  ```
191
192
 
192
- ### GET /reseller/transactions
193
+ ### `GET /reseller/transactions`
193
194
 
194
195
  Returns a list of all the transactions for the reseller.
195
196
 
@@ -205,7 +206,7 @@ Gyft::Transaction {
205
206
  }
206
207
  ```
207
208
 
208
- ### GET /transactions/last/:number_of_records
209
+ ### `GET /transactions/last/:number_of_records`
209
210
 
210
211
  Returns a limited list of recent transactions for the reseller.
211
212
 
@@ -221,7 +222,7 @@ Gyft::Transaction {
221
222
  }
222
223
  ```
223
224
 
224
- ### GET /transactions/first/:number_of_records
225
+ ### `GET /transactions/first/:number_of_records`
225
226
 
226
227
  Returns a limited list of initial transactions for the reseller.
227
228
 
@@ -237,7 +238,7 @@ Gyft::Transaction {
237
238
  }
238
239
  ```
239
240
 
240
- ### GET /transaction/:id
241
+ ### `GET /transaction/:id`
241
242
 
242
243
  Returns a full details for a sent transaction
243
244
 
@@ -258,7 +259,7 @@ Gyft::Transaction {
258
259
  }
259
260
  ```
260
261
 
261
- ### POST /transaction/refund
262
+ ### `POST /transaction/refund`
262
263
 
263
264
  Refund transaction and get card details.
264
265
 
@@ -278,7 +279,9 @@ Gyft::Refund {
278
279
  }
279
280
  ```
280
281
 
281
- ### POST /partner/purchase/gift_card_direct
282
+ ### `POST /partner/purchase/gift_card_direct`
283
+
284
+ Purchase a gift card returning a direct link to the card.
282
285
 
283
286
  ```rb
284
287
  > client.partner.purchase.gift_card_direct(
@@ -7,7 +7,8 @@ module Gyft
7
7
  class ServerError < StandardError; end
8
8
  class NotFoundError < StandardError; end
9
9
  class BadRequestError < StandardError; end
10
-
10
+ class UnauthorizedError < StandardError; end
11
+
11
12
  ENDPOINTS = {
12
13
  'production' => 'api.gyft.com',
13
14
  'sandbox' => 'apitest.gyft.com'
@@ -98,6 +99,8 @@ module Gyft
98
99
  raise NotFoundError, "Record not found (404)"
99
100
  when Net::HTTPBadRequest
100
101
  raise BadRequestError, "Bad request (400)"
102
+ when Net::HTTPUnauthorized
103
+ raise UnauthorizedError, "Access Denied (401)"
101
104
  else
102
105
  if json?(response)
103
106
  raise ServerError, "HTTP #{response.code}: #{JSON.parse(response.body)}"
@@ -1,3 +1,3 @@
1
1
  module Gyft
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -79,6 +79,15 @@ describe 'Gyft::Client' do
79
79
  result['details'].first['id'].must_equal 4
80
80
  end
81
81
 
82
+ it "should raise on 401" do
83
+ stub_request(:get, /apitest.gyft.com\/mashery\/v1\/reseller\/categories/).
84
+ to_return(:status => 401)
85
+
86
+ assert_raises Gyft::Client::UnauthorizedError do
87
+ @client.get('/reseller/categories')
88
+ end
89
+ end
90
+
82
91
  it "should raise on 404" do
83
92
  stub_request(:get, /apitest.gyft.com\/mashery\/v1\/reseller\/categories/).
84
93
  to_return(:status => 404)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gyft
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cristiano Betta