paypal-sdk-rest 1.7.3 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +5 -14
  3. data/README.md +48 -243
  4. data/lib/lib.rb +95 -0
  5. data/lib/paypal-sdk-rest.rb +1 -2
  6. data/lib/paypal/core/access_token.rb +20 -0
  7. data/lib/paypal/core/paypal_environment.rb +38 -0
  8. data/lib/paypal/core/paypal_http_client.rb +52 -0
  9. data/lib/paypal/core/token_requests.rb +40 -0
  10. data/lib/paypal/core/version.rb +3 -0
  11. data/lib/v1/billing_agreements/agreement_bill_balance_request.rb +35 -0
  12. data/lib/v1/billing_agreements/agreement_cancel_request.rb +35 -0
  13. data/lib/v1/billing_agreements/agreement_create_request.rb +33 -0
  14. data/lib/v1/billing_agreements/agreement_execute_request.rb +31 -0
  15. data/lib/v1/billing_agreements/agreement_get_request.rb +31 -0
  16. data/lib/v1/billing_agreements/agreement_re_activate_request.rb +35 -0
  17. data/lib/v1/billing_agreements/agreement_set_balance_request.rb +35 -0
  18. data/lib/v1/billing_agreements/agreement_suspend_request.rb +35 -0
  19. data/lib/v1/billing_agreements/agreement_transactions_request.rb +41 -0
  20. data/lib/v1/billing_agreements/agreement_update_request.rb +35 -0
  21. data/lib/v1/billing_plans/plan_create_request.rb +33 -0
  22. data/lib/v1/billing_plans/plan_get_request.rb +31 -0
  23. data/lib/v1/billing_plans/plan_list_request.rb +49 -0
  24. data/lib/v1/billing_plans/plan_update_request.rb +35 -0
  25. data/lib/v1/customer_disputes/dispute_accept_claim_request.rb +35 -0
  26. data/lib/v1/customer_disputes/dispute_adjudicate_request.rb +35 -0
  27. data/lib/v1/customer_disputes/dispute_appeal_request.rb +35 -0
  28. data/lib/v1/customer_disputes/dispute_get_request.rb +31 -0
  29. data/lib/v1/customer_disputes/dispute_list_request.rb +59 -0
  30. data/lib/v1/customer_disputes/dispute_provide_evidence_request.rb +35 -0
  31. data/lib/v1/customer_disputes/dispute_require_evidence_request.rb +35 -0
  32. data/lib/v1/identity/user_consent.rb +45 -0
  33. data/lib/v1/identity/userinfo_get_request.rb +33 -0
  34. data/lib/v1/invoices/invoice_cancel_request.rb +35 -0
  35. data/lib/v1/invoices/invoice_create_request.rb +33 -0
  36. data/lib/v1/invoices/invoice_delete_external_payment_request.rb +33 -0
  37. data/lib/v1/invoices/invoice_delete_external_refund_request.rb +33 -0
  38. data/lib/v1/invoices/invoice_delete_request.rb +31 -0
  39. data/lib/v1/invoices/invoice_get_request.rb +31 -0
  40. data/lib/v1/invoices/invoice_list_request.rb +44 -0
  41. data/lib/v1/invoices/invoice_next_invoice_number_request.rb +29 -0
  42. data/lib/v1/invoices/invoice_qr_code_request.rb +46 -0
  43. data/lib/v1/invoices/invoice_record_payment_request.rb +35 -0
  44. data/lib/v1/invoices/invoice_record_refund_request.rb +35 -0
  45. data/lib/v1/invoices/invoice_remind_request.rb +35 -0
  46. data/lib/v1/invoices/invoice_search_request.rb +33 -0
  47. data/lib/v1/invoices/invoice_send_request.rb +36 -0
  48. data/lib/v1/invoices/invoice_update_request.rb +40 -0
  49. data/lib/v1/invoices/template_create_request.rb +33 -0
  50. data/lib/v1/invoices/template_delete_request.rb +31 -0
  51. data/lib/v1/invoices/template_get_request.rb +31 -0
  52. data/lib/v1/invoices/template_list_request.rb +34 -0
  53. data/lib/v1/invoices/template_update_request.rb +35 -0
  54. data/lib/v1/orders/orders_cancel_request.rb +31 -0
  55. data/lib/v1/orders/orders_create_request.rb +33 -0
  56. data/lib/v1/orders/orders_get_request.rb +31 -0
  57. data/lib/v1/orders/orders_pay_request.rb +35 -0
  58. data/lib/v1/payment_experience/web_profile_create_request.rb +33 -0
  59. data/lib/v1/payment_experience/web_profile_delete_request.rb +31 -0
  60. data/lib/v1/payment_experience/web_profile_get_request.rb +31 -0
  61. data/lib/v1/payment_experience/web_profile_list_request.rb +29 -0
  62. data/lib/v1/payment_experience/web_profile_partial_update_request.rb +35 -0
  63. data/lib/v1/payment_experience/web_profile_update_request.rb +35 -0
  64. data/lib/v1/payments/authorization_capture_request.rb +35 -0
  65. data/lib/v1/payments/authorization_get_request.rb +31 -0
  66. data/lib/v1/payments/authorization_reauthorize_request.rb +35 -0
  67. data/lib/v1/payments/authorization_void_request.rb +35 -0
  68. data/lib/v1/payments/capture_get_request.rb +31 -0
  69. data/lib/v1/payments/capture_refund_request.rb +39 -0
  70. data/lib/v1/payments/order_authorize_request.rb +35 -0
  71. data/lib/v1/payments/order_capture_request.rb +35 -0
  72. data/lib/v1/payments/order_get_request.rb +31 -0
  73. data/lib/v1/payments/order_void_request.rb +35 -0
  74. data/lib/v1/payments/payment_create_request.rb +37 -0
  75. data/lib/v1/payments/payment_execute_request.rb +43 -0
  76. data/lib/v1/payments/payment_get_request.rb +31 -0
  77. data/lib/v1/payments/payment_list_request.rb +69 -0
  78. data/lib/v1/payments/payment_update_request.rb +35 -0
  79. data/lib/v1/payments/refund_get_request.rb +31 -0
  80. data/lib/v1/payments/sale_get_request.rb +31 -0
  81. data/lib/v1/payments/sale_refund_request.rb +39 -0
  82. data/lib/v1/sync/search_get_request.rb +99 -0
  83. data/lib/v1/vault/credit_card_create_request.rb +33 -0
  84. data/lib/v1/vault/credit_card_delete_request.rb +31 -0
  85. data/lib/v1/vault/credit_card_get_request.rb +31 -0
  86. data/lib/v1/vault/credit_card_list_request.rb +79 -0
  87. data/lib/v1/vault/credit_card_update_request.rb +35 -0
  88. data/lib/v1/webhooks/available_event_type_list_request.rb +29 -0
  89. data/lib/v1/webhooks/event_get_request.rb +31 -0
  90. data/lib/v1/webhooks/event_list_request.rb +54 -0
  91. data/lib/v1/webhooks/event_resend_request.rb +35 -0
  92. data/lib/v1/webhooks/simulate_event_request.rb +33 -0
  93. data/lib/v1/webhooks/webhook_create_request.rb +33 -0
  94. data/lib/v1/webhooks/webhook_delete_request.rb +31 -0
  95. data/lib/v1/webhooks/webhook_get_request.rb +31 -0
  96. data/lib/v1/webhooks/webhook_list_event_subscriptions_request.rb +31 -0
  97. data/lib/v1/webhooks/webhook_list_request.rb +34 -0
  98. data/lib/v1/webhooks/webhook_update_request.rb +35 -0
  99. data/lib/v1/webhooks/webhook_verify_signature_request.rb +33 -0
  100. data/spec/integration/test_harness.rb +25 -0
  101. data/spec/integration/v1/billing_agreements/agreement_create_spec.rb +69 -0
  102. data/spec/integration/v1/billing_plans/plan_create_spec.rb +12 -0
  103. data/spec/integration/v1/billing_plans/plan_get_spec.rb +16 -0
  104. data/spec/integration/v1/billing_plans/plan_helper.rb +71 -0
  105. data/spec/integration/v1/billing_plans/plan_list_spec.rb +16 -0
  106. data/spec/integration/v1/billing_plans/plan_update_spec.rb +19 -0
  107. data/spec/integration/v1/customer_disputes/dispute_accept_claim_spec.rb +26 -0
  108. data/spec/integration/v1/customer_disputes/dispute_adjudicate_spec.rb +24 -0
  109. data/spec/integration/v1/customer_disputes/dispute_appeal_spec.rb +33 -0
  110. data/spec/integration/v1/customer_disputes/dispute_get_spec.rb +19 -0
  111. data/spec/integration/v1/customer_disputes/dispute_list_spec.rb +17 -0
  112. data/spec/integration/v1/customer_disputes/dispute_provide_evidence_spec.rb +32 -0
  113. data/spec/integration/v1/customer_disputes/dispute_require_evidence_spec.rb +24 -0
  114. data/spec/integration/v1/customer_disputes/test_image.png +0 -0
  115. data/spec/integration/v1/identity/userinfo_get_spec.rb +65 -0
  116. data/spec/integration/v1/invoices/invoice_cancel_spec.rb +23 -0
  117. data/spec/integration/v1/invoices/invoice_create_spec.rb +15 -0
  118. data/spec/integration/v1/invoices/invoice_delete_external_payment_spec.rb +23 -0
  119. data/spec/integration/v1/invoices/invoice_delete_external_refund_spec.rb +21 -0
  120. data/spec/integration/v1/invoices/invoice_delete_spec.rb +16 -0
  121. data/spec/integration/v1/invoices/invoice_get_spec.rb +18 -0
  122. data/spec/integration/v1/invoices/invoice_helper.rb +171 -0
  123. data/spec/integration/v1/invoices/invoice_list_spec.rb +20 -0
  124. data/spec/integration/v1/invoices/invoice_next_invoice_number_spec.rb +14 -0
  125. data/spec/integration/v1/invoices/invoice_qr_code_spec.rb +18 -0
  126. data/spec/integration/v1/invoices/invoice_record_payment_spec.rb +14 -0
  127. data/spec/integration/v1/invoices/invoice_record_refund_spec.rb +14 -0
  128. data/spec/integration/v1/invoices/invoice_remind_spec.rb +22 -0
  129. data/spec/integration/v1/invoices/invoice_search_spec.rb +20 -0
  130. data/spec/integration/v1/invoices/invoice_send_spec.rb +15 -0
  131. data/spec/integration/v1/invoices/invoice_update_spec.rb +26 -0
  132. data/spec/integration/v1/invoices/template_create_spec.rb +14 -0
  133. data/spec/integration/v1/invoices/template_delete_spec.rb +15 -0
  134. data/spec/integration/v1/invoices/template_get_spec.rb +18 -0
  135. data/spec/integration/v1/invoices/template_list_spec.rb +15 -0
  136. data/spec/integration/v1/invoices/template_update_spec.rb +62 -0
  137. data/spec/integration/v1/orders/orders_cancel_spec.rb +15 -0
  138. data/spec/integration/v1/orders/orders_create_spec.rb +17 -0
  139. data/spec/integration/v1/orders/orders_get_spec.rb +18 -0
  140. data/spec/integration/v1/orders/orders_helper.rb +36 -0
  141. data/spec/integration/v1/orders/orders_pay_spec.rb +19 -0
  142. data/spec/integration/v1/payment_experience/pe_helper.rb +35 -0
  143. data/spec/integration/v1/payment_experience/web_profile_create_spec.rb +20 -0
  144. data/spec/integration/v1/payment_experience/web_profile_delete_spec.rb +15 -0
  145. data/spec/integration/v1/payment_experience/web_profile_get_spec.rb +17 -0
  146. data/spec/integration/v1/payment_experience/web_profile_list_spec.rb +18 -0
  147. data/spec/integration/v1/payment_experience/web_profile_partial_update_spec.rb +32 -0
  148. data/spec/integration/v1/payment_experience/web_profile_update_spec.rb +44 -0
  149. data/spec/integration/v1/payments/authorization_capture_spec.rb +17 -0
  150. data/spec/integration/v1/payments/authorization_get_spec.rb +18 -0
  151. data/spec/integration/v1/payments/authorization_reauthorize_spec.rb +26 -0
  152. data/spec/integration/v1/payments/authorization_void_spec.rb +19 -0
  153. data/spec/integration/v1/payments/capture_get_spec.rb +20 -0
  154. data/spec/integration/v1/payments/capture_refund_spec.rb +27 -0
  155. data/spec/integration/v1/payments/order_authorize_spec.rb +20 -0
  156. data/spec/integration/v1/payments/order_capture_spec.rb +21 -0
  157. data/spec/integration/v1/payments/order_get_spec.rb +14 -0
  158. data/spec/integration/v1/payments/order_void_spec.rb +14 -0
  159. data/spec/integration/v1/payments/payment_create_spec.rb +13 -0
  160. data/spec/integration/v1/payments/payment_execute_spec.rb +19 -0
  161. data/spec/integration/v1/payments/payment_get_spec.rb +17 -0
  162. data/spec/integration/v1/payments/payment_list_spec.rb +16 -0
  163. data/spec/integration/v1/payments/payment_update_spec.rb +28 -0
  164. data/spec/integration/v1/payments/payments_helper.rb +78 -0
  165. data/spec/integration/v1/payments/refund_get_spec.rb +19 -0
  166. data/spec/integration/v1/payments/sale_get_spec.rb +18 -0
  167. data/spec/integration/v1/payments/sale_refund_spec.rb +18 -0
  168. data/spec/integration/v1/sync/search_get_spec.rb +34 -0
  169. data/spec/integration/v1/vault/credit_card_create_spec.rb +16 -0
  170. data/spec/integration/v1/vault/credit_card_delete_spec.rb +16 -0
  171. data/spec/integration/v1/vault/credit_card_get_spec.rb +17 -0
  172. data/spec/integration/v1/vault/credit_card_list_spec.rb +18 -0
  173. data/spec/integration/v1/vault/credit_card_update_spec.rb +26 -0
  174. data/spec/integration/v1/vault/vault_helper.rb +28 -0
  175. data/spec/integration/v1/webhooks/available_event_type_list_spec.rb +16 -0
  176. data/spec/integration/v1/webhooks/webhook_create_spec.rb +12 -0
  177. data/spec/integration/v1/webhooks/webhook_delete_spec.rb +13 -0
  178. data/spec/integration/v1/webhooks/webhook_get_spec.rb +16 -0
  179. data/spec/integration/v1/webhooks/webhook_helper.rb +42 -0
  180. data/spec/integration/v1/webhooks/webhook_list_event_subscriptions_spec.rb +16 -0
  181. data/spec/integration/v1/webhooks/webhook_list_spec.rb +15 -0
  182. data/spec/integration/v1/webhooks/webhook_update_spec.rb +29 -0
  183. data/spec/integration/v1/webhooks/webhook_verify_signature_spec.rb +20 -0
  184. data/spec/log/http.log +0 -0
  185. data/spec/log/rest_http.log +0 -0
  186. data/spec/spec_helper.rb +98 -26
  187. data/spec/unit/paypal_http_client_spec.rb +272 -0
  188. metadata +277 -119
  189. data/Rakefile +0 -15
  190. data/data/DigiCertHighAssuranceEVRootCA.pem +0 -23
  191. data/data/DigiCertSHA2ExtendedValidationServerCA.pem +0 -28
  192. data/data/paypal.crt +0 -171
  193. data/lib/generators/paypal/sdk/USAGE +0 -3
  194. data/lib/generators/paypal/sdk/install_generator.rb +0 -17
  195. data/lib/generators/paypal/sdk/templates/paypal.rb +0 -2
  196. data/lib/generators/paypal/sdk/templates/paypal.yml +0 -29
  197. data/lib/paypal-sdk-core.rb +0 -38
  198. data/lib/paypal-sdk/core/api.rb +0 -20
  199. data/lib/paypal-sdk/core/api/base.rb +0 -169
  200. data/lib/paypal-sdk/core/api/data_types/array_with_block.rb +0 -44
  201. data/lib/paypal-sdk/core/api/data_types/base.rb +0 -225
  202. data/lib/paypal-sdk/core/api/data_types/enum.rb +0 -26
  203. data/lib/paypal-sdk/core/api/data_types/simple_types.rb +0 -52
  204. data/lib/paypal-sdk/core/api/ipn.rb +0 -66
  205. data/lib/paypal-sdk/core/api/rest.rb +0 -177
  206. data/lib/paypal-sdk/core/authentication.rb +0 -66
  207. data/lib/paypal-sdk/core/config.rb +0 -253
  208. data/lib/paypal-sdk/core/credential.rb +0 -16
  209. data/lib/paypal-sdk/core/credential/base.rb +0 -27
  210. data/lib/paypal-sdk/core/credential/certificate.rb +0 -32
  211. data/lib/paypal-sdk/core/credential/signature.rb +0 -22
  212. data/lib/paypal-sdk/core/credential/third_party/subject.rb +0 -25
  213. data/lib/paypal-sdk/core/credential/third_party/token.rb +0 -39
  214. data/lib/paypal-sdk/core/exceptions.rb +0 -112
  215. data/lib/paypal-sdk/core/logging.rb +0 -50
  216. data/lib/paypal-sdk/core/openid_connect.rb +0 -140
  217. data/lib/paypal-sdk/core/openid_connect/api.rb +0 -50
  218. data/lib/paypal-sdk/core/openid_connect/data_types.rb +0 -73
  219. data/lib/paypal-sdk/core/openid_connect/get_api.rb +0 -28
  220. data/lib/paypal-sdk/core/openid_connect/request_data_type.rb +0 -52
  221. data/lib/paypal-sdk/core/openid_connect/set_api.rb +0 -36
  222. data/lib/paypal-sdk/core/util.rb +0 -11
  223. data/lib/paypal-sdk/core/util/http_helper.rb +0 -171
  224. data/lib/paypal-sdk/core/util/oauth_signature.rb +0 -64
  225. data/lib/paypal-sdk/core/util/ordered_hash.rb +0 -165
  226. data/lib/paypal-sdk/rest.rb +0 -39
  227. data/lib/paypal-sdk/rest/api.rb +0 -23
  228. data/lib/paypal-sdk/rest/data_types.rb +0 -2596
  229. data/lib/paypal-sdk/rest/error_hash.rb +0 -39
  230. data/lib/paypal-sdk/rest/get_api.rb +0 -20
  231. data/lib/paypal-sdk/rest/request_data_type.rb +0 -53
  232. data/lib/paypal-sdk/rest/set_api.rb +0 -42
  233. data/lib/paypal-sdk/rest/version.rb +0 -7
  234. data/spec/README.md +0 -22
  235. data/spec/config/cacert.pem +0 -171
  236. data/spec/config/cert_key.pem +0 -33
  237. data/spec/config/paypal.yml +0 -35
  238. data/spec/config/sample_data.yml +0 -3
  239. data/spec/core/api/data_type_spec.rb +0 -289
  240. data/spec/core/api/rest_spec.rb +0 -211
  241. data/spec/core/config_spec.rb +0 -192
  242. data/spec/core/logging_spec.rb +0 -28
  243. data/spec/core/openid_connect_spec.rb +0 -153
  244. data/spec/invoice_examples_spec.rb +0 -38
  245. data/spec/payments_examples_spec.rb +0 -437
  246. data/spec/payouts_examples_spec.rb +0 -49
  247. data/spec/rest/data_types_spec.rb +0 -62
  248. data/spec/rest/error_hash_spec.rb +0 -83
  249. data/spec/subscription_examples_spec.rb +0 -227
  250. data/spec/support/sample_data.rb +0 -5
  251. data/spec/web_profile_examples_spec.rb +0 -106
  252. data/spec/webhooks_examples_spec.rb +0 -93
@@ -1,49 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Payouts", :integration => true do
4
-
5
- PayoutAttributes = {
6
- :sender_batch_header => {
7
- :sender_batch_id => SecureRandom.hex(8),
8
- :email_subject => 'You have a Payout!'
9
- },
10
- :items => [
11
- {
12
- :recipient_type => 'EMAIL',
13
- :amount => {
14
- :value => '1.0',
15
- :currency => 'USD'
16
- },
17
- :note => 'Thanks for your patronage!',
18
- :sender_item_id => '2014031400023',
19
- :receiver => 'shirt-supplier-one@mail.com'
20
- }
21
- ]
22
- }
23
-
24
- it "create payout sync" do
25
- $payout = PayPal::SDK::REST::Payout.new(PayoutAttributes)
26
- $payout_batch = $payout.create(true)
27
- expect($payout_batch).to be_truthy
28
- end
29
-
30
- it "get payout batch status" do
31
- $result = PayPal::SDK::REST::Payout.get($payout_batch.batch_header.payout_batch_id)
32
- expect($result).to be_a PayPal::SDK::REST::PayoutBatch
33
- expect($payout_batch.batch_header.payout_batch_id).to eql $result.batch_header.payout_batch_id
34
- end
35
-
36
- it "get payout item status" do
37
- $payout_item_details= PayoutItem.get($payout_batch.items[0].payout_item_id)
38
- expect($payout_item_details).to be_a PayPal::SDK::REST::PayoutItemDetails
39
- expect($payout_item_details.payout_item_id).to eql $payout_batch.items[0].payout_item_id
40
- end
41
-
42
- it "cancel unclaimed payouts" do
43
- $payout_item_details= PayoutItem.cancel($payout_batch.items[0].payout_item_id)
44
- expect($payout_item_details).to be_a PayPal::SDK::REST::PayoutItemDetails
45
- expect($payout_item_details.payout_item_id).to eql $payout_batch.items[0].payout_item_id
46
- expect($payout_item_details.transaction_status).to eql 'RETURNED'
47
- end
48
-
49
- end
@@ -1,62 +0,0 @@
1
- module PayPal::SDK::REST::DataTypes
2
- describe Base do
3
- let(:error_object) {
4
- {
5
- "name" => "INVALID_EXPERIENCE_PROFILE_ID",
6
- "message" => "The requested experience profile ID was not found",
7
- "information_link" => "https://developer.paypal.com/docs/api/#INVALID_EXPERIENCE_PROFILE_ID",
8
- "debug_id" => "1562931a79fd2"
9
- }
10
- }
11
-
12
- context '#raise_error!' do
13
- context 'when there is error' do
14
- subject { described_class.new(error: error_object) }
15
-
16
- it 'raises error on request with all API information' do
17
- expect { subject.raise_error! }
18
- .to raise_error { |err|
19
- expect(err).to be_a(PayPal::SDK::Core::Exceptions::UnsuccessfulApiCall)
20
- expect(err.message).to eq("The requested experience profile ID was not found")
21
- expect(err.api_error).to eq(error_object)
22
- }
23
- end
24
- end
25
-
26
- context 'when there is no error' do
27
- subject { described_class.new(error: nil) }
28
-
29
- it { expect { subject.raise_error! }.not_to raise_error }
30
- end
31
- end
32
-
33
- context '.raise_on_api_error' do
34
- let(:klass) {
35
- Class.new(described_class) do
36
- def some_call
37
- end
38
-
39
- raise_on_api_error :some_call
40
- end
41
- }
42
-
43
- subject { klass.new }
44
-
45
- context 'when call is successful' do
46
- before {
47
- expect(subject).to receive(:some_call).and_return(true)
48
- }
49
- it { expect { subject.some_call! }.not_to raise_error }
50
- end
51
-
52
- context 'when call is unsuccessful' do
53
- before {
54
- expect(subject).to receive(:some_call).and_return(false)
55
- expect(subject).to receive(:error).twice.and_return(error_object)
56
- }
57
-
58
- it { expect { subject.some_call! }.to raise_error(PayPal::SDK::Core::Exceptions::UnsuccessfulApiCall) }
59
- end
60
- end
61
- end
62
- end
@@ -1,83 +0,0 @@
1
- module PayPal::SDK::REST
2
- describe ErrorHash do
3
- it 'converts Hashes to ErrorHashes' do
4
- hash = ErrorHash.convert({
5
- nested_hash: { bing: 'bong' },
6
- empty_array: [],
7
- array_with_hashes: [
8
- { foo: 'boo' },
9
- { biz: 'boz' }
10
- ],
11
- array_without_hashes: [1, 2, 3],
12
- nilly: nil,
13
- stringy: 'cheese'
14
- })
15
-
16
- expect(hash).to be_a(ErrorHash)
17
- expect(hash.nested_hash).to be_a(ErrorHash)
18
- expect(hash.empty_array).to eq([])
19
- expect(hash.array_with_hashes[0]).to be_a(ErrorHash)
20
- expect(hash.array_with_hashes[1]).to be_a(ErrorHash)
21
- expect(hash.array_without_hashes).to eq([1, 2, 3])
22
- expect(hash.nilly).to be_nil
23
- expect(hash.stringy).to eq('cheese')
24
- end
25
-
26
- it 'can access string keys as properties, strings, or symbols' do
27
- hash = ErrorHash.convert({ 'foo' => 5 })
28
- hash['boo'] = 'grue'
29
-
30
- expect(hash.foo).to eq(5)
31
- expect(hash['foo']).to eq(5)
32
- expect(hash[:foo]).to eq(5)
33
- expect(hash.boo).to eq('grue')
34
- expect(hash['boo']).to eq('grue')
35
- expect(hash[:boo]).to eq('grue')
36
- end
37
-
38
- it 'can access symbol keys as properties, strings, or symbols' do
39
- hash = ErrorHash.convert({ :foo => 5 })
40
- hash[:boo] = 'grue'
41
-
42
- expect(hash.foo).to eq(5)
43
- expect(hash['foo']).to eq(5)
44
- expect(hash[:foo]).to eq(5)
45
- expect(hash.boo).to eq('grue')
46
- expect(hash['boo']).to eq('grue')
47
- expect(hash[:boo]).to eq('grue')
48
- end
49
-
50
- it 'converts Hashes to ErrorHashes on assignment' do
51
- hash = ErrorHash.new
52
- hash['foo'] = { bing: 'bong' }
53
-
54
- expect(hash['foo']).to be_a(ErrorHash)
55
- expect(hash['foo'].bing).to eq('bong')
56
- end
57
-
58
- it 'converts Hashes inside of Arrays to ErrorHashes on assignment' do
59
- hash = ErrorHash.new
60
- hash['foo'] = [{ bing: 'bong' }]
61
-
62
- expect(hash['foo'][0]).to be_a(ErrorHash)
63
- expect(hash['foo'][0].bing).to eq('bong')
64
- end
65
-
66
- it "doesn't convert Hashes inside of Arrays if the first element of the array isn't a Hash" do
67
- hash = ErrorHash.new
68
- hash['foo'] = [100, { bing: 'bong' }]
69
-
70
- expect(hash['foo'][1]).to be_a(Hash)
71
- expect(hash['foo'][1]).not_to be_a(ErrorHash)
72
- end
73
-
74
- it 'gets and sets numbers and strings' do
75
- hash = ErrorHash.new
76
- hash['foo'] = 123
77
- hash['boo'] = 'baa'
78
-
79
- expect(hash['foo']).to eq(123)
80
- expect(hash['boo']).to eq('baa')
81
- end
82
- end
83
- end
@@ -1,227 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Subscription" do
4
-
5
- PlanAttributes = {
6
- "name" => "T-Shirt of the Month Club Plan",
7
- "description" => "Template creation.",
8
- "type" => "fixed",
9
- "payment_definitions" => [
10
- {
11
- "name" => "Regular Payments",
12
- "type" => "REGULAR",
13
- "frequency" => "MONTH",
14
- "frequency_interval" => "2",
15
- "amount" => {
16
- "value" => "100",
17
- "currency" => "USD"
18
- },
19
- "cycles" => "12",
20
- "charge_models" => [
21
- {
22
- "type" => "SHIPPING",
23
- "amount" => {
24
- "value" => "10",
25
- "currency" => "USD"
26
- }
27
- },
28
- {
29
- "type" => "TAX",
30
- "amount" => {
31
- "value" => "12",
32
- "currency" => "USD"
33
- }
34
- }
35
- ]
36
- }
37
- ],
38
- "merchant_preferences" => {
39
- "setup_fee" => {
40
- "value" => "1",
41
- "currency" => "USD"
42
- },
43
- "return_url" => "http://www.return.com",
44
- "cancel_url" => "http://www.cancel.com",
45
- "auto_bill_amount" => "YES",
46
- "initial_fail_amount_action" => "CONTINUE",
47
- "max_fail_attempts" => "0"
48
- }
49
- }
50
-
51
- AgreementAttributes = {
52
- "name" => "T-Shirt of the Month Club Agreement",
53
- "description" => "Agreement for T-Shirt of the Month Club Plan",
54
- "start_date" => "2015-02-19T00:37:04Z",
55
- "payer" => {
56
- "payment_method" => "paypal"
57
- },
58
- "shipping_address" => {
59
- "line1" => "111 First Street",
60
- "city" => "Saratoga",
61
- "state" => "CA",
62
- "postal_code" => "95070",
63
- "country_code" => "US"
64
- }
65
- }
66
-
67
- describe "BillingPlan", :integration => true do
68
- it "Create" do
69
- # create access token and then create a plan
70
- $api = API.new
71
- plan = Plan.new(PlanAttributes.merge( :token => $api.token ))
72
- expect(Plan.api).not_to eql plan.api
73
- plan.create
74
-
75
- # make sure the transaction was successful
76
- $plan_id = plan.id
77
- expect(plan.error).to be_nil
78
- expect(plan.id).not_to be_nil
79
- end
80
-
81
- it "Update" do
82
- # create a new plan to update
83
- plan = Plan.new(PlanAttributes)
84
- expect(plan.create).to be_truthy
85
-
86
- # set up a patch request
87
- patch = Patch.new
88
- patch.op = "replace"
89
- patch.path = "/";
90
- patch.value = { :state => "ACTIVE" }
91
-
92
- # the patch request should be successful
93
- expect(plan.update( patch )).to be_truthy
94
- end
95
-
96
- it "List" do
97
- # list all billing plans
98
- plan_list = Plan.all
99
- expect(plan_list.error).to be_nil
100
- expect(plan_list.plans.count).to be > 1
101
- end
102
-
103
- it "Delete" do
104
- # create a plan to delete
105
- plan = Plan.new(PlanAttributes.merge( :token => $api.token ))
106
- plan.create
107
- plan_id = plan.id
108
-
109
- # construct a patch object that will be used for deletion
110
- patch = Patch.new
111
- patch.op = "replace"
112
- patch.path = "/"
113
- patch.value = { "state" => "DELETED" }
114
-
115
- # send delete request
116
- plan.update(patch)
117
-
118
- # make sure the plan has been deleted
119
- plan = Plan.find(plan_id)
120
- expect(plan.id).not_to eq plan_id
121
- end
122
- end
123
-
124
- describe "BillingAgreement", :integration => true do
125
-
126
- it "Create" do
127
- # first, create an active plan to be added to agreement
128
- api = API.new
129
- plan = Plan.new(PlanAttributes)
130
- expect(plan.create).to be_truthy
131
-
132
- # first, create an agreement
133
- $agreement = Agreement.new(AgreementAttributes)
134
- $agreement.plan = Plan.new( :id => "P-1K47639161110773GYDKTWIA" )
135
- $agreement.shipping_address = nil
136
-
137
- # verify newly created agreement
138
- expect($agreement.create).to be_truthy
139
- expect($agreement.id).to be_nil
140
- expect($agreement.token).not_to be_nil
141
- expect($agreement.name).to eq("T-Shirt of the Month Club Agreement")
142
- end
143
-
144
- #####################################
145
- # The following tests are disabled due to them requiring an active billing agreement or buyer's approval.
146
- # Most of them require an agreement ID, which is returned after executing agreement.
147
- # And agreement execution requires buyer's approval.
148
- #####################################
149
-
150
- xit "Execute" do
151
- # Use this call to execute an agreement after the buyer approves it.
152
- expect($agreement.execute).to be_truthy
153
- end
154
-
155
- xit "Get" do
156
- # this call needs an agreement ID of the agreement to be retrieved
157
- agreement = Agreement.find($agreement.id)
158
- expect(agreement.id).to eq($agreement.id)
159
- expect(agreement.description).to eq("Agreement for T-Shirt of the Month Club Plan")
160
- expect(agreement.start_date).to eq("2015-02-19T00:37:04Z")
161
- expect(agreement.plan).not_to be_nil
162
- end
163
-
164
- xit "Update" do
165
- # get the agreement to update
166
- api = API.new
167
- plan = Plan.new(PlanAttributes)
168
- expect(plan.create).to be_truthy
169
-
170
- # first, create an agreement
171
- agreement = Agreement.new(AgreementAttributes)
172
- agreement.plan = Plan.new( :id => "P-1K47639161110773GYDKTWIA" )
173
- expect(agreement.create).to be_truthy
174
-
175
-
176
- # create an update for the agreement
177
- random_string = (0...8).map { (65 + rand(26)).chr }.join
178
- patch = Patch.new
179
- patch.op = "replace"
180
- patch.path = "/"
181
- patch.value = { "description" => random_string }
182
-
183
- # send update request
184
- response = agreement.update(patch)
185
-
186
- # verify the agreement update was successful
187
- expect(response).to be_truthy
188
- updated_agreement = Agreement.get($agreement.id)
189
- expect(updated_agreement.id).to eq($agreement.id)
190
- expect(random_string).to eq(updated_agreement.description)
191
- end
192
-
193
- xit "Suspend" do
194
- # set the id of an active agreement here
195
- agreement_id = ""
196
- agreement = Agreement.find(agreement_id)
197
-
198
- state_descriptor = AgreementStateDescriptor.new( :note => "Suspending the agreement" )
199
- expect( agreement.suspend(state_descriptor) ).to be_truthy
200
- end
201
-
202
- xit "Reactivate" do
203
- # set the id of a suspended agreement here
204
- agreement_id = ""
205
- agreement = Agreement.find(agreement_id)
206
-
207
- state_descriptor = AgreementStateDescriptor.new( :note => "Re-activating the agreement" )
208
- expect( agreement.re_activate(state_descriptor) ).to be_truthy
209
- end
210
-
211
- xit "Search" do
212
- transactions = Agreement.transactions($agreement.id, "2015-01-01", "2015-01-10")
213
- expect(transactions).not_to be_nil
214
- expect(transactions.agreement_transaction_list).not_to be_empty
215
- end
216
-
217
- xit "Cancel" do
218
- # set the id of an agreement here
219
- agreement_id = ""
220
- agreement = Agreement.find(agreement_id)
221
-
222
- state_descriptor = AgreementStateDescriptor.new( :note => "Cancelling the agreement" )
223
- expect( agreement.cancel(state_descriptor) ).to be_truthy
224
- end
225
-
226
- end
227
- end
@@ -1,5 +0,0 @@
1
- module SampleData
2
- def samples
3
- @@samples ||= YAML.load(File.read(File.expand_path("../../config/sample_data.yml", __FILE__)))
4
- end
5
- end
@@ -1,106 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "WebProfiles" do
4
-
5
- WebProfileAttributes = {
6
- "name" => "YeowZa! T-Shirt Shop",
7
- "presentation" => {
8
- "brand_name" => "YeowZa! Paypal",
9
- "logo_image" => "http://www.yeowza.com",
10
- "locale_code" => "US"
11
- },
12
- "input_fields" => {
13
- "allow_note" => true,
14
- "no_shipping" => 0,
15
- "address_override" => 1
16
- },
17
- "flow_config" => {
18
- "landing_page_type" => "billing",
19
- "bank_txn_pending_url" => "http://www.yeowza.com"
20
- }
21
- }
22
-
23
- describe "Examples" do
24
- describe "WebProfile", :integration => true do
25
- it "Create" do
26
-
27
- api = API.new
28
- $webprofile = WebProfile.new(WebProfileAttributes.merge( :token => api.token ))
29
-
30
- # generate a random number and append it to name
31
- suffix = Random.rand(1000000000).to_s
32
- $randname = $webprofile.name + suffix
33
- $webprofile.name = $randname
34
-
35
- # create webhook
36
- $webprofile.create
37
- expect($webprofile).to be_an_instance_of(WebProfile)
38
- expect($webprofile.name.to_s).to eq($randname)
39
- end
40
-
41
- it "List" do
42
- list = WebProfile.get_list
43
- expect(list.size).to be > 1
44
- expect(list.first).to be_an_instance_of(WebProfileList)
45
- end
46
-
47
- it "Retrieve" do
48
- webprofile = WebProfile.find($webprofile.id)
49
- expect(webprofile).to be_an_instance_of(WebProfile)
50
- expect(webprofile.name.to_s).to eq($randname)
51
- end
52
-
53
- it "Update" do
54
- # append "-test" to web profile name
55
- webprofile = WebProfile.find($webprofile.id)
56
- webprofile.name += "-test"
57
- webprofile.update
58
-
59
- # check whether the name was updated
60
- webprofile = WebProfile.find($webprofile.id)
61
- expect(webprofile.name).to eq($randname + "-test")
62
- webprofile.name = $randname
63
- webprofile.update
64
-
65
- # revert updated profile name for next test run
66
- webprofile = WebProfile.find($webprofile.id)
67
- expect(webprofile.name).to eq($randname)
68
- end
69
-
70
- it "Partial update" do
71
- # retrieve web profile to perform partial update on
72
- webprofile = WebProfile.find($webprofile.id)
73
-
74
- # set up partial update
75
- h = {"op" => "replace",
76
- "path" => "/presentation/brand_name",
77
- "value" => "new_brand_name"}
78
-
79
- # do partial update by sending a patch request
80
- expect(webprofile.partial_update( [h] )).to be_truthy
81
- webprofile = WebProfile.find($webprofile.id)
82
- expect(webprofile.presentation.brand_name).to eq("new_brand_name")
83
-
84
- # restore original value for the next test run
85
- h = {"op" => "replace",
86
- "path" => "/presentation/brand_name",
87
- "value" => "brand_name"}
88
- expect(webprofile.partial_update( [h] )).to be_truthy
89
- expect(WebProfile.find($webprofile.id).presentation.brand_name).to eq("brand_name")
90
- end
91
-
92
- it "Delete" do
93
- # delete newly created web profile from above create test
94
- expect($webprofile.delete).to be_truthy
95
-
96
- # make sure it is not retrieved from the system
97
- begin
98
- webprofile = WebProfile.find($webprofile.id)
99
- expect(webprofile).to be_nil
100
- fail "WebProfile with ID=#{$webprofile.id} has not been deleted"
101
- rescue ResourceNotFound
102
- end
103
- end
104
- end
105
- end
106
- end