roku-iap 0.0.2 → 0.0.3

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: d435b5c2748726d3e917f8b0fec72b6e16885f5a
4
- data.tar.gz: a6ebbaa700422a0a9d6b26949b52536b279332c2
3
+ metadata.gz: 53b277c94090e4c601880538cbe0603b02928646
4
+ data.tar.gz: fea1cae621667b988fea913cb35cce804851ee28
5
5
  SHA512:
6
- metadata.gz: a6ebef7a72067e028e887c7243142ebbbd30ed4d19f8f7a49886d891b54eab98314b1e52645594dd4c5f1d689f301ce25ef07b7da7c508a1f8eb31314dcd03aa
7
- data.tar.gz: d254892a91d2ede5c85ab3721cd5f47458cb1f35e16a46be67d4c5647ea0d07690acd2c695eb36a39a4eb34d854c67702faa56f17e30a52ba54deef9f5818d03
6
+ metadata.gz: 2dbc4745c5f9325eb0660f855b20675df1c81be9f4d4b6244bd2928d178b1c81beed8f66ab365fab0c8624f14d9514e1b863253216a6042688a2c82704d0a122
7
+ data.tar.gz: e382d585cb5d1171b609967231ae9c6e3b5c0f38956973aa5e34fc5bf29231db147c5b4a839ebe5a9649ae786fbae64dcf93432b06f57157591f51e80879b5ce
data/README.md CHANGED
@@ -46,12 +46,16 @@ else
46
46
  end
47
47
  ```
48
48
 
49
- Non-200 status code responses will raise a Roku::Iap::Exceptions::General, and are distinct from errors returned by the Roku API (which you may call ```result.error_message``` to elaborate upon)
49
+ ## Exceptions
50
+
51
+ Non-200 status code responses will raise a Roku::Iap::Exceptions::General exception, and are distinct from errors returned by the Roku API (which you may call ```result.error_message``` to elaborate upon). A 404 can be presumed to be a nil devtoken parameter, and will raise a Roku::Iap::Exceptions::InvalidCredentials exception.
52
+
53
+ All defined exceptions inherit from Roku::Iap::Exceptions::Exception, and can be handled as:
50
54
 
51
55
  ```ruby
52
56
  begin
53
57
  result = client.validate_transaction 'some-transaction-id'
54
- rescue Roku::Iap::Exceptions::General => e
58
+ rescue Roku::Iap::Exceptions::Exception => e
55
59
  # enqueue to try again later
56
60
  end
57
61
  ```
@@ -32,6 +32,12 @@ class Roku::Iap::Client
32
32
  end
33
33
 
34
34
  def refund_subscription(transaction_id, amount, partner_ref_id="", comments="")
35
+
36
+ unless amount.match(/\d+/)
37
+ # The Roku API returns 400 if amount is not parsable
38
+ raise Roku::Iap::Exceptions::TypeError, "Ensure amount is integer or float!"
39
+ end
40
+
35
41
  path = "/listen/transaction-service.svc/refund-subscription"
36
42
  request_body_json = {
37
43
  :partnerApiKey => @dev_token,
@@ -1,7 +1,10 @@
1
1
  module Roku
2
2
  module Iap
3
3
  module Exceptions
4
- class General < Exception; end
4
+ class Exception < Exception; end
5
+ class General < Roku::Iap::Exceptions::Exception; end
6
+ class InvalidCredentials < Roku::Iap::Exceptions::Exception; end
7
+ class TypeError < Roku::Iap::Exceptions::Exception; end
5
8
  end
6
9
  end
7
10
  end
@@ -12,8 +12,10 @@ class Roku::Iap::Response
12
12
  self.class.class_eval("attr_accessor :#{underscore}")
13
13
  send "#{underscore}=", e.text.nil? ? "" : e.text
14
14
  end
15
+ elsif response.code.to_i == 404
16
+ raise Roku::Iap::Exceptions::InvalidCredentials, "Ensure that your Roku API key is not nil!"
15
17
  else
16
- raise Roku::Iap::Exceptions::General, response.code.to_i
18
+ raise Roku::Iap::Exceptions::General, response.body
17
19
  end
18
20
  end
19
21
 
@@ -1,5 +1,5 @@
1
1
  module Roku
2
2
  module Iap
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roku-iap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - DailyBurn