roku-iap 0.0.2 → 0.0.3
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 +4 -4
- data/README.md +6 -2
- data/lib/roku/iap/client.rb +6 -0
- data/lib/roku/iap/exceptions.rb +4 -1
- data/lib/roku/iap/response.rb +3 -1
- data/lib/roku/iap/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53b277c94090e4c601880538cbe0603b02928646
|
4
|
+
data.tar.gz: fea1cae621667b988fea913cb35cce804851ee28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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::
|
58
|
+
rescue Roku::Iap::Exceptions::Exception => e
|
55
59
|
# enqueue to try again later
|
56
60
|
end
|
57
61
|
```
|
data/lib/roku/iap/client.rb
CHANGED
@@ -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,
|
data/lib/roku/iap/exceptions.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
module Roku
|
2
2
|
module Iap
|
3
3
|
module Exceptions
|
4
|
-
class
|
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
|
data/lib/roku/iap/response.rb
CHANGED
@@ -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.
|
18
|
+
raise Roku::Iap::Exceptions::General, response.body
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
data/lib/roku/iap/version.rb
CHANGED