tylerhunt-remit 0.0.1 → 0.0.4

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.
Files changed (48) hide show
  1. data/LICENSE +1 -1
  2. data/README.markdown +91 -0
  3. data/lib/remit.rb +51 -41
  4. data/lib/remit/common.rb +16 -16
  5. data/lib/remit/data_types.rb +59 -2
  6. data/lib/remit/error_codes.rb +118 -0
  7. data/lib/remit/get_pipeline.rb +65 -7
  8. data/lib/remit/ipn_request.rb +49 -0
  9. data/lib/remit/{cancel_token.rb → operations/cancel_token.rb} +1 -1
  10. data/lib/remit/{discard_results.rb → operations/discard_results.rb} +1 -1
  11. data/lib/remit/{fund_prepaid.rb → operations/fund_prepaid.rb} +6 -6
  12. data/lib/remit/{get_account_activity.rb → operations/get_account_activity.rb} +1 -1
  13. data/lib/remit/{get_account_balance.rb → operations/get_account_balance.rb} +0 -0
  14. data/lib/remit/{get_all_credit_instruments.rb → operations/get_all_credit_instruments.rb} +0 -0
  15. data/lib/remit/{get_all_prepaid_instruments.rb → operations/get_all_prepaid_instruments.rb} +0 -0
  16. data/lib/remit/{get_debt_balance.rb → operations/get_debt_balance.rb} +1 -1
  17. data/lib/remit/{get_outstanding_debt_balance.rb → operations/get_outstanding_debt_balance.rb} +0 -0
  18. data/lib/remit/{get_payment_instruction.rb → operations/get_payment_instruction.rb} +1 -1
  19. data/lib/remit/{get_prepaid_balance.rb → operations/get_prepaid_balance.rb} +1 -1
  20. data/lib/remit/{get_results.rb → operations/get_results.rb} +4 -3
  21. data/lib/remit/{get_token_by_caller.rb → operations/get_token_by_caller.rb} +0 -0
  22. data/lib/remit/{get_token_usage.rb → operations/get_token_usage.rb} +1 -1
  23. data/lib/remit/{get_tokens.rb → operations/get_tokens.rb} +0 -0
  24. data/lib/remit/{get_total_prepaid_liability.rb → operations/get_total_prepaid_liability.rb} +0 -0
  25. data/lib/remit/{get_transaction.rb → operations/get_transaction.rb} +1 -1
  26. data/lib/remit/{install_payment_instruction.rb → operations/install_payment_instruction.rb} +3 -3
  27. data/lib/remit/operations/pay.rb +35 -0
  28. data/lib/remit/{refund.rb → operations/refund.rb} +6 -8
  29. data/lib/remit/{reserve.rb → operations/reserve.rb} +6 -6
  30. data/lib/remit/{retry_transaction.rb → operations/retry_transaction.rb} +1 -1
  31. data/lib/remit/{settle.rb → operations/settle.rb} +2 -2
  32. data/lib/remit/{settle_debt.rb → operations/settle_debt.rb} +6 -6
  33. data/lib/remit/{subscribe_for_caller_notification.rb → operations/subscribe_for_caller_notification.rb} +2 -2
  34. data/lib/remit/{unsubscribe_for_caller_notification.rb → operations/unsubscribe_for_caller_notification.rb} +1 -1
  35. data/lib/remit/{write_off_debt.rb → operations/write_off_debt.rb} +4 -4
  36. data/lib/remit/pipeline_response.rb +52 -0
  37. data/spec/{get_account_activity_spec.rb → integrations/get_account_activity_spec.rb} +4 -4
  38. data/spec/{get_tokens_spec.rb → integrations/get_tokens_spec.rb} +3 -3
  39. data/spec/integrations/integrations_helper.rb +8 -0
  40. data/spec/spec_helper.rb +20 -10
  41. data/spec/{get_pipeline_spec.rb → units/get_pipeline_spec.rb} +83 -24
  42. data/spec/units/get_results_spec.rb +49 -0
  43. data/spec/units/ipn_request_spec.rb +32 -0
  44. data/spec/units/pay_spec.rb +133 -0
  45. data/spec/units/units_helper.rb +4 -0
  46. metadata +49 -45
  47. data/README +0 -38
  48. data/lib/remit/pay.rb +0 -34
@@ -0,0 +1,133 @@
1
+ require File.dirname(__FILE__) + '/units_helper'
2
+
3
+ describe "the Pay API" do
4
+ describe "a successful response" do
5
+ it_should_behave_like 'a successful response'
6
+
7
+ before do
8
+ doc = <<-XML
9
+ <ns3:PayResponse xmlns:ns3="http://fps.amazonaws.com/doc/2007-01-08/">
10
+ <ns3:TransactionResponse>
11
+ <TransactionId>abc123</TransactionId>
12
+ <Status>Initiated</Status>
13
+ </ns3:TransactionResponse>
14
+ <Status>Success</Status>
15
+ <RequestId>foo</RequestId>
16
+ </ns3:PayResponse>
17
+ XML
18
+
19
+ @response = Remit::Pay::Response.new(doc)
20
+ end
21
+
22
+ it "has a transaction response" do
23
+ @response.transaction_response.should_not be_nil
24
+ end
25
+
26
+ it "has a transaction id" do
27
+ @response.transaction_response.transaction_id.should == 'abc123'
28
+ end
29
+
30
+ it "has a transaction status" do
31
+ @response.transaction_response.status.should == 'Initiated'
32
+ end
33
+
34
+ it "has status shortcuts" do
35
+ @response.transaction_response.should be_initiated
36
+ end
37
+ end
38
+
39
+ describe "for a failed request" do
40
+ before do
41
+ doc = <<-XML
42
+ <?xml version=\"1.0\"?>
43
+ <ns3:PayResponse xmlns:ns3=\"http://fps.amazonaws.com/doc/2007-01-08/\">
44
+ <Status>Failure</Status>
45
+ <Errors>
46
+ <Errors>
47
+ <ErrorType>Business</ErrorType>
48
+ <IsRetriable>false</IsRetriable>
49
+ <ErrorCode>InvalidParams</ErrorCode>
50
+ <ReasonText>callerTokenId can not be empty</ReasonText>
51
+ </Errors>
52
+ </Errors>
53
+ <RequestId>7966a2d9-5ce9-4902-aefc-b01d254c931a:0</RequestId>
54
+ </ns3:PayResponse>
55
+ XML
56
+
57
+ @response = Remit::Pay::Response.new(doc)
58
+ @error = @response.errors.first
59
+ end
60
+
61
+ it_should_behave_like 'a failed response'
62
+
63
+ describe "with an invalid params error" do
64
+ it "should be a service error" do
65
+ @error.should be_kind_of(Remit::ServiceError)
66
+ end
67
+
68
+ it "should have an error type of 'Business'" do
69
+ @error.error_type.should == 'Business'
70
+ end
71
+
72
+ it "should have an error code of 'InvalidParams'" do
73
+ @error.error_code.should == 'InvalidParams'
74
+ end
75
+
76
+ it "should not be retriable" do
77
+ @error.is_retriable.should == 'false'
78
+ end
79
+
80
+ it "should have reason text" do
81
+ @error.reason_text.should == 'callerTokenId can not be empty'
82
+ end
83
+ end
84
+ end
85
+
86
+ describe "for a failed request" do
87
+ before do
88
+ doc = <<-XML
89
+ <?xml version=\"1.0\"?>
90
+ <ns3:PayResponse xmlns:ns3=\"http://fps.amazonaws.com/doc/2007-01-08/\">
91
+ <Status>Failure</Status>
92
+ <Errors>
93
+ <Errors>
94
+ <ErrorType>Business</ErrorType>
95
+ <IsRetriable>false</IsRetriable>
96
+ <ErrorCode>TokenUsageError</ErrorCode>
97
+ <ReasonText>The token \"45XU7TLBN995ZQA2U1PS1ZCTJXJMJ3H1GH6VZAB82C1BGLK9X3AXUQDA3QDLJVPX\" has violated its usage policy.</ReasonText>
98
+ </Errors>
99
+ </Errors>
100
+ <RequestId>78acff80-b740-4b57-9301-18d0576e6855:0
101
+ </RequestId>
102
+ </ns3:PayResponse>
103
+ XML
104
+
105
+ @response = Remit::Pay::Response.new(doc)
106
+ @error = @response.errors.first
107
+ end
108
+
109
+ it_should_behave_like 'a failed response'
110
+
111
+ describe "with a token usage error" do
112
+ it "should be a service error" do
113
+ @error.should be_kind_of(Remit::ServiceError)
114
+ end
115
+
116
+ it "should have an error type of 'Business'" do
117
+ @error.error_type.should == 'Business'
118
+ end
119
+
120
+ it "should have an error code of 'TokenUsageError'" do
121
+ @error.error_code.should == 'TokenUsageError'
122
+ end
123
+
124
+ it "should not be retriable" do
125
+ @error.is_retriable.should == 'false'
126
+ end
127
+
128
+ it "should have reason text" do
129
+ @error.reason_text.should == 'The token "45XU7TLBN995ZQA2U1PS1ZCTJXJMJ3H1GH6VZAB82C1BGLK9X3AXUQDA3QDLJVPX" has violated its usage policy.'
130
+ end
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,4 @@
1
+ ACCESS_KEY = 'foo'
2
+ SECRET_KEY = 'bar'
3
+
4
+ require File.dirname(__FILE__) + '/../spec_helper'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tylerhunt-remit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Hunt
@@ -9,17 +9,18 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-20 00:00:00 -07:00
12
+ date: 2009-04-27 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: relax
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
20
- - - ">="
21
+ - - ~>
21
22
  - !ruby/object:Gem::Version
22
- version: 0.0.3
23
+ version: 0.0.7
23
24
  version:
24
25
  description:
25
26
  email: tyler@tylerhunt.com
@@ -28,52 +29,50 @@ executables: []
28
29
  extensions: []
29
30
 
30
31
  extra_rdoc_files:
31
- - README
32
32
  - LICENSE
33
+ - README.markdown
33
34
  files:
34
- - lib/remit
35
- - lib/remit/cancel_token.rb
35
+ - lib/remit.rb
36
36
  - lib/remit/common.rb
37
37
  - lib/remit/data_types.rb
38
- - lib/remit/discard_results.rb
39
- - lib/remit/fund_prepaid.rb
40
- - lib/remit/get_account_activity.rb
41
- - lib/remit/get_account_balance.rb
42
- - lib/remit/get_all_credit_instruments.rb
43
- - lib/remit/get_all_prepaid_instruments.rb
44
- - lib/remit/get_debt_balance.rb
45
- - lib/remit/get_outstanding_debt_balance.rb
46
- - lib/remit/get_payment_instruction.rb
38
+ - lib/remit/error_codes.rb
47
39
  - lib/remit/get_pipeline.rb
48
- - lib/remit/get_prepaid_balance.rb
49
- - lib/remit/get_results.rb
50
- - lib/remit/get_token_by_caller.rb
51
- - lib/remit/get_token_usage.rb
52
- - lib/remit/get_tokens.rb
53
- - lib/remit/get_total_prepaid_liability.rb
54
- - lib/remit/get_transaction.rb
55
- - lib/remit/install_payment_instruction.rb
56
- - lib/remit/pay.rb
57
- - lib/remit/refund.rb
58
- - lib/remit/reserve.rb
59
- - lib/remit/retry_transaction.rb
60
- - lib/remit/settle.rb
61
- - lib/remit/settle_debt.rb
62
- - lib/remit/subscribe_for_caller_notification.rb
63
- - lib/remit/unsubscribe_for_caller_notification.rb
64
- - lib/remit/write_off_debt.rb
65
- - lib/remit.rb
66
- - spec/get_account_activity_spec.rb
67
- - spec/get_pipeline_spec.rb
68
- - spec/get_tokens_spec.rb
69
- - spec/spec_helper.rb
70
- - README
40
+ - lib/remit/ipn_request.rb
41
+ - lib/remit/operations/cancel_token.rb
42
+ - lib/remit/operations/discard_results.rb
43
+ - lib/remit/operations/fund_prepaid.rb
44
+ - lib/remit/operations/get_account_activity.rb
45
+ - lib/remit/operations/get_account_balance.rb
46
+ - lib/remit/operations/get_all_credit_instruments.rb
47
+ - lib/remit/operations/get_all_prepaid_instruments.rb
48
+ - lib/remit/operations/get_debt_balance.rb
49
+ - lib/remit/operations/get_outstanding_debt_balance.rb
50
+ - lib/remit/operations/get_payment_instruction.rb
51
+ - lib/remit/operations/get_prepaid_balance.rb
52
+ - lib/remit/operations/get_results.rb
53
+ - lib/remit/operations/get_token_by_caller.rb
54
+ - lib/remit/operations/get_token_usage.rb
55
+ - lib/remit/operations/get_tokens.rb
56
+ - lib/remit/operations/get_total_prepaid_liability.rb
57
+ - lib/remit/operations/get_transaction.rb
58
+ - lib/remit/operations/install_payment_instruction.rb
59
+ - lib/remit/operations/pay.rb
60
+ - lib/remit/operations/refund.rb
61
+ - lib/remit/operations/reserve.rb
62
+ - lib/remit/operations/retry_transaction.rb
63
+ - lib/remit/operations/settle.rb
64
+ - lib/remit/operations/settle_debt.rb
65
+ - lib/remit/operations/subscribe_for_caller_notification.rb
66
+ - lib/remit/operations/unsubscribe_for_caller_notification.rb
67
+ - lib/remit/operations/write_off_debt.rb
68
+ - lib/remit/pipeline_response.rb
71
69
  - LICENSE
70
+ - README.markdown
72
71
  has_rdoc: true
73
- homepage: http://tylerhunt.com/
72
+ homepage: http://github.com/tylerhunt/remit
74
73
  post_install_message:
75
- rdoc_options: []
76
-
74
+ rdoc_options:
75
+ - --charset=UTF-8
77
76
  require_paths:
78
77
  - lib
79
78
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -96,7 +95,12 @@ signing_key:
96
95
  specification_version: 2
97
96
  summary: An API for using the Amazon Flexible Payment Service (FPS).
98
97
  test_files:
99
- - spec/get_account_activity_spec.rb
100
- - spec/get_pipeline_spec.rb
101
- - spec/get_tokens_spec.rb
98
+ - spec/integrations/get_account_activity_spec.rb
99
+ - spec/integrations/get_tokens_spec.rb
100
+ - spec/units/get_pipeline_spec.rb
101
+ - spec/units/get_results_spec.rb
102
+ - spec/units/ipn_request_spec.rb
103
+ - spec/units/pay_spec.rb
104
+ - spec/integrations/integrations_helper.rb
102
105
  - spec/spec_helper.rb
106
+ - spec/units/units_helper.rb
data/README DELETED
@@ -1,38 +0,0 @@
1
- Remit
2
- =====
3
-
4
- This API provides access to the Amazon Flexible Payment Service (FPS). After
5
- trying to get the SOAP version of the API written, I began working on this REST
6
- version to provide a cohesive means of access to all of the functionality of
7
- the FPS without having to get dirty dealing with SOAP requests.
8
-
9
- I hope you enjoy using it as much as I've enjoyed writing it. I'm interested to
10
- hear what sort of uses you find for it. If you find any bugs, let me know (or
11
- better yet, submit a patch).
12
-
13
-
14
- Sandbox
15
- -------
16
- Amazon provides a testing environment for the FPS called a sandbox. You may
17
- (and should) use the sandbox while testing your application. It can be enabled
18
- by passing a value of true to the last argument of the API constructor.
19
-
20
-
21
- Example
22
- -------
23
- The following example shows how to load up the API, initialize the service, and
24
- make a simple call to get the tokens stored on the account:
25
-
26
- require 'remit'
27
-
28
- ACCESS_KEY = '<your AWS access key>'
29
- SECRET_KEY = '<your AWS secret key>'
30
-
31
- # connect using the API's sandbox mode
32
- remit = Remit::API.new(ACCESS_KEY, SECRET_KEY, true)
33
-
34
- response = remit.get_tokens
35
- puts response.tokens.first.token_id
36
-
37
-
38
- Copyright (c) 2007-2008 Tyler Hunt, released under the MIT license
data/lib/remit/pay.rb DELETED
@@ -1,34 +0,0 @@
1
- require 'remit/common'
2
-
3
- module Remit
4
- module Pay
5
- class Request < Remit::Request
6
- action :Pay
7
- parameter :caller_description
8
- parameter :caller_reference
9
- parameter :caller_token_id
10
- parameter :charge_fee_to
11
- parameter :meta_data
12
- parameter :recipient_description
13
- parameter :recipient_reference
14
- parameter :recipient_token_id
15
- parameter :sender_description
16
- parameter :sender_reference
17
- parameter :sender_token_id
18
- parameter :transaction_amount, :type => Remit::RequestTypes::Amount
19
- parameter :transaction_date
20
- end
21
-
22
- class Response < Remit::Response
23
- # FIXME: Due to an issue with Hpricot, Relax-0.0.4, and namespaces, the
24
- # transaction_response parameter is not parsed correctly and will always
25
- # be nil (http://groups.google.com/group/remit/t/1e0af072200d1bb3).
26
- # The suggested course of action is to operate on the raw XML.
27
- parameter :transaction_response, :type => TransactionResponse
28
- end
29
-
30
- def pay(request = Request.new)
31
- call(request, Response)
32
- end
33
- end
34
- end