fat_zebra 2.0.13 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.rubocop.yml +42 -0
- data/.travis.yml +9 -2
- data/Gemfile +1 -1
- data/{README.markdown → README.md} +19 -20
- data/Rakefile +2 -12
- data/fat_zebra.gemspec +27 -0
- data/lib/fat_zebra/api_operation/delete.rb +38 -0
- data/lib/fat_zebra/api_operation/find.rb +23 -0
- data/lib/fat_zebra/api_operation/save.rb +62 -0
- data/lib/fat_zebra/api_operation/search.rb +32 -0
- data/lib/fat_zebra/api_operation/void.rb +52 -0
- data/lib/fat_zebra/api_resource.rb +135 -0
- data/lib/fat_zebra/bank_account.rb +21 -0
- data/lib/fat_zebra/batch.rb +56 -0
- data/lib/fat_zebra/card.rb +22 -0
- data/lib/fat_zebra/config.rb +65 -25
- data/lib/fat_zebra/customer.rb +27 -0
- data/lib/fat_zebra/direct_credit.rb +27 -0
- data/lib/fat_zebra/direct_debit.rb +27 -0
- data/lib/fat_zebra/errors.rb +18 -4
- data/lib/fat_zebra/fat_zebra_object.rb +179 -0
- data/lib/fat_zebra/information.rb +25 -0
- data/lib/fat_zebra/payment_plan.rb +62 -0
- data/lib/fat_zebra/purchase.rb +99 -0
- data/lib/fat_zebra/refund.rb +25 -0
- data/lib/fat_zebra/request/multipart/epilogue.rb +23 -0
- data/lib/fat_zebra/request/multipart/file_io.rb +40 -0
- data/lib/fat_zebra/request/multipart/param.rb +37 -0
- data/lib/fat_zebra/request/multipart/part.rb +28 -0
- data/lib/fat_zebra/request/multipart/stream.rb +55 -0
- data/lib/fat_zebra/request.rb +162 -0
- data/lib/fat_zebra/util.rb +70 -0
- data/lib/fat_zebra/validation.rb +47 -0
- data/lib/fat_zebra/version.rb +1 -1
- data/lib/fat_zebra/web_hook.rb +23 -0
- data/lib/fat_zebra.rb +51 -55
- data/spec/cassettes/FatZebra_BankAccount/_create/1_1_1.yml +57 -0
- data/spec/cassettes/FatZebra_BankAccount/_create/1_1_2.yml +57 -0
- data/spec/cassettes/FatZebra_BankAccount/_create/validations/1_1_3_1.yml +57 -0
- data/spec/cassettes/FatZebra_BankAccount/_search/1_2_1.yml +172 -0
- data/spec/cassettes/FatZebra_BankAccount/_search/1_2_2.yml +172 -0
- data/spec/cassettes/FatZebra_BankAccount/_search/1_2_3.yml +172 -0
- data/spec/cassettes/FatZebra_Batch/_create/1_1_1.yml +58 -0
- data/spec/cassettes/FatZebra_Batch/_create/1_1_2.yml +58 -0
- data/spec/cassettes/FatZebra_Batch/_create/validations/1_1_3_1.yml +57 -0
- data/spec/cassettes/FatZebra_Batch/_create/with_file/1_1_1_1.yml +58 -0
- data/spec/cassettes/FatZebra_Batch/_create/with_file/1_1_1_2.yml +58 -0
- data/spec/cassettes/FatZebra_Batch/_create/with_path/1_1_2_1.yml +58 -0
- data/spec/cassettes/FatZebra_Batch/_create/with_path/1_1_2_2.yml +58 -0
- data/spec/cassettes/FatZebra_Batch/_find/1_2_1.yml +109 -0
- data/spec/cassettes/FatZebra_Batch/_find/1_2_2.yml +109 -0
- data/spec/cassettes/FatZebra_Batch/_result/1_4_1.yml +160 -0
- data/spec/cassettes/FatZebra_Batch/_search/1_3_1.yml +54 -0
- data/spec/cassettes/FatZebra_Batch/_search/1_3_2.yml +54 -0
- data/spec/cassettes/FatZebra_Batch/_search/1_3_3.yml +54 -0
- data/spec/cassettes/FatZebra_Card/_create/1_1_1.yml +55 -0
- data/spec/cassettes/FatZebra_Card/_create/1_1_2.yml +55 -0
- data/spec/cassettes/FatZebra_Card/_create/1_1_3.yml +55 -0
- data/spec/cassettes/FatZebra_Card/_create/1_1_4.yml +55 -0
- data/spec/cassettes/FatZebra_Card/_create/1_1_5.yml +55 -0
- data/spec/cassettes/FatZebra_Card/_create/1_1_6.yml +55 -0
- data/spec/cassettes/FatZebra_Card/_create/validations/1_1_7_1.yml +56 -0
- data/spec/cassettes/FatZebra_Card/_update/1_2_1.yml +105 -0
- data/spec/cassettes/FatZebra_Card/_update/1_2_2.yml +105 -0
- data/spec/cassettes/FatZebra_Card/_update/1_2_3.yml +105 -0
- data/spec/cassettes/FatZebra_Card/_update/validations/1_2_4_1.yml +55 -0
- data/spec/cassettes/FatZebra_Customer/_create/1_1_1.yml +59 -0
- data/spec/cassettes/FatZebra_Customer/_create/1_1_2.yml +59 -0
- data/spec/cassettes/FatZebra_Customer/_create/1_1_3.yml +59 -0
- data/spec/cassettes/FatZebra_Customer/_create/1_1_4.yml +59 -0
- data/spec/cassettes/FatZebra_Customer/_create/1_1_5.yml +59 -0
- data/spec/cassettes/FatZebra_Customer/_create/1_1_6.yml +59 -0
- data/spec/cassettes/FatZebra_Customer/_create/validations/1_1_7_1.yml +56 -0
- data/spec/cassettes/FatZebra_Customer/_delete/1_4_1.yml +113 -0
- data/spec/cassettes/FatZebra_Customer/_delete/1_5_1.yml +113 -0
- data/spec/cassettes/FatZebra_Customer/_find/1_2_1.yml +111 -0
- data/spec/cassettes/FatZebra_Customer/_find/1_2_2.yml +111 -0
- data/spec/cassettes/FatZebra_Customer/_find/1_3_1.yml +111 -0
- data/spec/cassettes/FatZebra_Customer/_find/1_3_2.yml +111 -0
- data/spec/cassettes/FatZebra_Customer/_search/1_2_1.yml +56 -0
- data/spec/cassettes/FatZebra_Customer/_search/1_2_2.yml +56 -0
- data/spec/cassettes/FatZebra_Customer/_search/1_2_3.yml +56 -0
- data/spec/cassettes/FatZebra_Customer/_update/1_3_1.yml +114 -0
- data/spec/cassettes/FatZebra_Customer/_update/1_3_2.yml +114 -0
- data/spec/cassettes/FatZebra_Customer/_update/1_4_1.yml +114 -0
- data/spec/cassettes/FatZebra_Customer/_update/1_4_2.yml +114 -0
- data/spec/cassettes/FatZebra_DirectCredit/_create/1_1_1.yml +56 -0
- data/spec/cassettes/FatZebra_DirectCredit/_create/1_1_2.yml +56 -0
- data/spec/cassettes/FatZebra_DirectCredit/_create/1_1_3.yml +56 -0
- data/spec/cassettes/FatZebra_DirectCredit/_create/1_1_4.yml +56 -0
- data/spec/cassettes/FatZebra_DirectCredit/_create/validations/1_1_5_1.yml +59 -0
- data/spec/cassettes/FatZebra_DirectCredit/_delete/1_4_1.yml +109 -0
- data/spec/cassettes/FatZebra_DirectCredit/_find/1_2_1.yml +107 -0
- data/spec/cassettes/FatZebra_DirectCredit/_find/1_2_2.yml +107 -0
- data/spec/cassettes/FatZebra_DirectCredit/_search/1_3_1.yml +160 -0
- data/spec/cassettes/FatZebra_DirectCredit/_search/1_3_2.yml +160 -0
- data/spec/cassettes/FatZebra_DirectDebit/_create/1_1_1.yml +56 -0
- data/spec/cassettes/FatZebra_DirectDebit/_create/1_1_2.yml +56 -0
- data/spec/cassettes/FatZebra_DirectDebit/_create/1_1_3.yml +56 -0
- data/spec/cassettes/FatZebra_DirectDebit/_create/1_1_4.yml +56 -0
- data/spec/cassettes/FatZebra_DirectDebit/_create/validations/1_1_5_1.yml +59 -0
- data/spec/cassettes/FatZebra_DirectDebit/_delete/1_4_1.yml +109 -0
- data/spec/cassettes/FatZebra_DirectDebit/_find/1_2_1.yml +107 -0
- data/spec/cassettes/FatZebra_DirectDebit/_find/1_2_2.yml +107 -0
- data/spec/cassettes/FatZebra_DirectDebit/_search/1_3_1.yml +160 -0
- data/spec/cassettes/FatZebra_DirectDebit/_search/1_3_2.yml +160 -0
- data/spec/cassettes/FatZebra_Information/_ping/1_1_1.yml +54 -0
- data/spec/cassettes/FatZebra_Information/_ping/1_1_2.yml +54 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_active_/1_7_1.yml +238 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_active_/1_7_2.yml +238 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_active_/1_8_1.yml +238 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_active_/1_8_2.yml +238 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_create/1_1_1.yml +118 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_create/1_1_2.yml +118 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_create/1_1_3.yml +118 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_create/validations/1_1_4_1.yml +55 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_delete/1_5_1.yml +172 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_destroy/1_6_1.yml +172 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_find/1_2_1.yml +175 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_find/1_2_2.yml +175 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_find/1_2_3.yml +175 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_suspend_/1_6_1.yml +178 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_suspend_/1_6_2.yml +178 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_suspend_/1_7_1.yml +178 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_suspend_/1_7_2.yml +178 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_update/1_3_1.yml +172 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_update/1_3_2.yml +172 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_update/1_3_3.yml +172 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_update/1_4_1.yml +178 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_update/1_4_2.yml +178 -0
- data/spec/cassettes/FatZebra_Purchase/_capture/1_5_1.yml +111 -0
- data/spec/cassettes/FatZebra_Purchase/_capture/1_5_2.yml +111 -0
- data/spec/cassettes/FatZebra_Purchase/_capture/1_6_1.yml +111 -0
- data/spec/cassettes/FatZebra_Purchase/_capture/1_6_2.yml +111 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_1.yml +57 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_10.yml +57 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_11.yml +57 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_12.yml +57 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_2.yml +57 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_3.yml +57 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_4.yml +57 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_5.yml +57 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_6.yml +57 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_7.yml +57 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_8.yml +57 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_9.yml +57 -0
- data/spec/cassettes/FatZebra_Purchase/_find/1_2_1.yml +109 -0
- data/spec/cassettes/FatZebra_Purchase/_find/1_2_2.yml +109 -0
- data/spec/cassettes/FatZebra_Purchase/_find/1_2_3.yml +109 -0
- data/spec/cassettes/FatZebra_Purchase/_find/1_4_1.yml +109 -0
- data/spec/cassettes/FatZebra_Purchase/_find/1_4_2.yml +109 -0
- data/spec/cassettes/FatZebra_Purchase/_find/1_4_3.yml +109 -0
- data/spec/cassettes/FatZebra_Purchase/_refund/1_4_1.yml +111 -0
- data/spec/cassettes/FatZebra_Purchase/_refund/1_4_2.yml +111 -0
- data/spec/cassettes/FatZebra_Purchase/_refund/1_5_1.yml +111 -0
- data/spec/cassettes/FatZebra_Purchase/_refund/1_5_2.yml +111 -0
- data/spec/cassettes/FatZebra_Purchase/_search/1_3_1.yml +170 -0
- data/spec/cassettes/FatZebra_Purchase/_search/1_3_2.yml +170 -0
- data/spec/cassettes/FatZebra_Purchase/_search/1_3_3.yml +170 -0
- data/spec/cassettes/FatZebra_Purchase/_search/with_data/1_3_2_1.yml +164 -0
- data/spec/cassettes/FatZebra_Purchase/_search/with_data/1_3_2_2.yml +165 -0
- data/spec/cassettes/FatZebra_Purchase/_search/with_data/1_3_2_3.yml +164 -0
- data/spec/cassettes/FatZebra_Purchase/_search/without_data/1_3_1_1.yml +54 -0
- data/spec/cassettes/FatZebra_Purchase/_search/without_data/1_3_1_2.yml +54 -0
- data/spec/cassettes/FatZebra_Purchase/_search/without_data/1_3_1_3.yml +54 -0
- data/spec/cassettes/FatZebra_Purchase/_settlement/1_8_1.yml +613 -0
- data/spec/cassettes/FatZebra_Purchase/_settlement/1_8_2.yml +615 -0
- data/spec/cassettes/FatZebra_Purchase/_settlement/1_8_3.yml +617 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_6_1.yml +111 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_6_2.yml +111 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_6_3.yml +111 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_7_1.yml +111 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_7_2.yml +111 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_7_3.yml +111 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_1.yml +111 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_2.yml +111 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_3.yml +111 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_4.yml +111 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_5.yml +111 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_6.yml +111 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_7.yml +111 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_8.yml +111 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_9.yml +111 -0
- data/spec/cassettes/FatZebra_Refund/_find/1_2_1.yml +163 -0
- data/spec/cassettes/FatZebra_Refund/_find/1_2_2.yml +163 -0
- data/spec/cassettes/FatZebra_Refund/_search/1_3_1.yml +281 -0
- data/spec/cassettes/FatZebra_Refund/_search/1_3_2.yml +281 -0
- data/spec/cassettes/FatZebra_Refund/_void/1_4_1.yml +165 -0
- data/spec/cassettes/FatZebra_Refund/_void/1_4_2.yml +165 -0
- data/spec/cassettes/FatZebra_Refund/_void/1_4_3.yml +165 -0
- data/spec/cassettes/FatZebra_WebHook/_create/1_1_1.yml +57 -0
- data/spec/cassettes/FatZebra_WebHook/_create/1_1_2.yml +57 -0
- data/spec/cassettes/FatZebra_WebHook/_create/1_1_3.yml +57 -0
- data/spec/cassettes/FatZebra_WebHook/_create/validations/1_1_4_1.yml +56 -0
- data/spec/cassettes/FatZebra_WebHook/_delete/1_4_1.yml +111 -0
- data/spec/cassettes/FatZebra_WebHook/_search/1_2_1.yml +222 -0
- data/spec/cassettes/FatZebra_WebHook/_search/1_2_2.yml +224 -0
- data/spec/cassettes/FatZebra_WebHook/_update/1_3_1.yml +112 -0
- data/spec/cassettes/FatZebra_WebHook/_update/1_3_2.yml +112 -0
- data/spec/fixtures/batch_test.csv +4 -0
- data/spec/lib/fat_zebra/bank_account_spec.rb +34 -0
- data/spec/lib/fat_zebra/batch_spec.rb +59 -0
- data/spec/lib/fat_zebra/card_spec.rb +41 -0
- data/spec/lib/fat_zebra/config_spec.rb +52 -0
- data/spec/lib/fat_zebra/customer_spec.rb +53 -0
- data/spec/lib/fat_zebra/direct_credit_spec.rb +53 -0
- data/spec/lib/fat_zebra/direct_debit_spec.rb +53 -0
- data/spec/lib/fat_zebra/fat_zebra_object_spec.rb +116 -0
- data/spec/lib/fat_zebra/information_spec.rb +13 -0
- data/spec/lib/fat_zebra/payment_plan_spec.rb +94 -0
- data/spec/lib/fat_zebra/purchase_spec.rb +92 -0
- data/spec/lib/fat_zebra/refund_spec.rb +72 -0
- data/spec/lib/fat_zebra/util_spec.rb +24 -0
- data/spec/lib/fat_zebra/validation_spec.rb +22 -0
- data/spec/lib/fat_zebra/web_hook_spec.rb +50 -0
- data/spec/spec_helper.rb +49 -3
- data/spec/support/payloads.rb +43 -0
- metadata +238 -65
- data/FatZebra.gemspec +0 -31
- data/lib/fat_zebra/constants.rb +0 -2
- data/lib/fat_zebra/gateway.rb +0 -292
- data/lib/fat_zebra/models/base.rb +0 -33
- data/lib/fat_zebra/models/card.rb +0 -49
- data/lib/fat_zebra/models/purchase.rb +0 -185
- data/lib/fat_zebra/models/refund.rb +0 -46
- data/lib/fat_zebra/models/response.rb +0 -33
- data/lib/rest-client/request_ext.rb +0 -15
- data/spec/config_spec.rb +0 -37
- data/spec/gateway_spec.rb +0 -120
- data/spec/models/purchase_spec.rb +0 -55
- data/spec/models/refund_spec.rb +0 -9
- data/spec/models/response_spec.rb +0 -25
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
OGExZDFlYzVkODNlYWFhZDkwY2ZkZGQ3MzE1NDRmODFjYzNjODE1NQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a2d528ebf041ec5f73b61570237e3547dc3d9d45
|
4
|
+
data.tar.gz: c8b2990d36c46054972c47fe5272f21002e648b6
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YTAxMGRkOGE2N2FjNjU0M2FjNjMxZjA4MzE5MzI4ZmYyNzlhODNlNDY1ODVj
|
11
|
-
ODJkOTUzOGE2NTVmMmZhY2Y3YjMwNTk1MzIzMjVjNjU2NGJmNGM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZjE3NDVhNmIyNWVjNjNkOTNmOTBmZWY0OTVlNDAxOTkzOGYxNTRlOWQwMTkz
|
14
|
-
MjM3ZDk5OWU5ZjllYTcxMWM2Y2I1ZWQ1MzkxNjhiYWYyM2RhNTM3NmM4MmI3
|
15
|
-
NzQ5NmU4MmMyMzJmNmIzNTE5YzNhNDBhYWZiMWZjY2Q3ZGU5NDM=
|
6
|
+
metadata.gz: 92da2daddc57c3250bc439cb7a29553de9fb0db58536ff01e34fe77cc22604ac26f129075eae2b6b40af0fa5a3c53b541c9c89f99b8d558808bcce07b65fa1a4
|
7
|
+
data.tar.gz: 590f8fc2a63c58f2e1004bbddb1ebadccebf81f25c0e1d94336c2ccf62b2522cb5f35f5973e575ac28262fe39c89d25baac574d4817b767de2cc95348b160f96
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Layout/EmptyLinesAroundClassBody:
|
2
|
+
Enabled: false
|
3
|
+
Layout/EmptyLinesAroundModuleBody:
|
4
|
+
Enabled: false
|
5
|
+
Layout/EmptyLinesAroundBlockBody:
|
6
|
+
Enabled: false
|
7
|
+
|
8
|
+
Style/MethodMissing:
|
9
|
+
Enabled: false
|
10
|
+
Style/NumericPredicate:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/AbcSize:
|
14
|
+
# The ABC size is a calculated magnitude, so this number can be a Fixnum or
|
15
|
+
# a Float.
|
16
|
+
Max: 25
|
17
|
+
Metrics/LineLength:
|
18
|
+
Max: 200
|
19
|
+
Metrics/ClassLength:
|
20
|
+
CountComments: false
|
21
|
+
Max: 200
|
22
|
+
Metrics/MethodLength:
|
23
|
+
CountComments: false
|
24
|
+
Max: 25
|
25
|
+
Metrics/ModuleLength:
|
26
|
+
CountComments: false
|
27
|
+
Max: 200
|
28
|
+
|
29
|
+
Documentation:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
AllCops:
|
33
|
+
TargetRubyVersion: 2.2
|
34
|
+
Include:
|
35
|
+
- Gemfile
|
36
|
+
- Rakefile
|
37
|
+
- Capfile
|
38
|
+
Exclude:
|
39
|
+
- bin/**/*
|
40
|
+
- vendor/**/*
|
41
|
+
- tmp/**/*
|
42
|
+
- spec/**/*
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
Ruby API Library for Fat Zebra
|
2
2
|
==============================
|
3
3
|
|
4
|
-
|
4
|
+
[![Build Status](https://travis-ci.org/fatzebra/Ruby-Library.svg?branch=master)](https://travis-ci.org/fatzebra/Ruby-Library)
|
5
|
+
|
6
|
+
Release 3.0.0 for API version 1.0
|
5
7
|
|
6
8
|
A Ruby client for the [Fat Zebra](https://www.fatzebra.com.au) Online Payment Gateway (for Australian Merchants)
|
7
9
|
|
8
10
|
Dependencies
|
9
11
|
------------
|
10
12
|
|
11
|
-
* Ruby (tested on 1.
|
13
|
+
* Ruby (tested on 2.0, 2.1, 2.2, 2.3, 2.4)
|
12
14
|
* Rest Client
|
13
|
-
* JSON
|
14
|
-
|
15
|
-
[![Build Status](https://secure.travis-ci.org/fatzebra/Ruby-Library.png?branch=master)](http://travis-ci.org/fatzebra/Ruby-Library)
|
16
15
|
|
17
16
|
Installing
|
18
17
|
----------
|
@@ -31,24 +30,24 @@ require 'fat_zebra'
|
|
31
30
|
|
32
31
|
# Configuration only needs to be done once, usually in your rails initializers
|
33
32
|
FatZebra.configure do |config|
|
34
|
-
config.username
|
35
|
-
config.token
|
36
|
-
config.gateway "gateway.fatzebra.com.au"
|
33
|
+
config.username = 'TEST'
|
34
|
+
config.token = 'TEST'
|
37
35
|
end
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
37
|
+
purchase = FatZebra::Purchase.create(
|
38
|
+
amount: 10000,
|
39
|
+
card_holder: 'Bill Simpson',
|
40
|
+
card_number: '5123456789012346',
|
41
|
+
card_expiry: '05/2023',
|
42
|
+
cvv: '123',
|
43
|
+
reference: 'ORDER-23',
|
44
|
+
customer_ip: '203.99.87.4'
|
45
|
+
)
|
46
|
+
|
47
|
+
if purchase.successful?
|
48
|
+
puts "Transaction ID: #{purchase.id}"
|
50
49
|
else
|
51
|
-
|
50
|
+
abort "Error in transaction: #{purchase.errors}"
|
52
51
|
end
|
53
52
|
```
|
54
53
|
|
data/Rakefile
CHANGED
@@ -1,18 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
2
|
|
3
3
|
require 'rspec/core/rake_task'
|
4
4
|
|
5
5
|
RSpec::Core::RakeTask.new('spec')
|
6
6
|
|
7
7
|
# If you want to make this the default task
|
8
|
-
task :
|
9
|
-
|
10
|
-
begin
|
11
|
-
require 'yard'
|
12
|
-
desc "Run the YARDdoc task"
|
13
|
-
task :yard do
|
14
|
-
exec "yardoc --plugin yard-tomdoc"
|
15
|
-
end
|
16
|
-
rescue LoadError
|
17
|
-
puts "Please install the Yard gem to create docs"
|
18
|
-
end
|
8
|
+
task default: :spec
|
data/fat_zebra.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'fat_zebra/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'fat_zebra'
|
8
|
+
s.version = FatZebra::VERSION
|
9
|
+
s.authors = ['Matthew Savage']
|
10
|
+
s.email = ['matt@amasses.net']
|
11
|
+
s.homepage = ''
|
12
|
+
s.summary = 'Fat Zebra payments gem - integrate your ruby app with Fat Zebra'
|
13
|
+
s.description = 'Provides integration with the Fat Zebra internet payment gateway (www.fatzebra.com.au), including purchase, refund, auth, capture and recurring billing functionality.'
|
14
|
+
|
15
|
+
s.rubyforge_project = 'fat_zebra'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
19
|
+
s.require_paths = %w[lib]
|
20
|
+
|
21
|
+
s.add_development_dependency 'rspec'
|
22
|
+
s.add_development_dependency 'rake'
|
23
|
+
s.add_development_dependency 'pry'
|
24
|
+
s.add_development_dependency 'vcr'
|
25
|
+
s.add_development_dependency 'webmock'
|
26
|
+
s.add_development_dependency 'rubocop'
|
27
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module FatZebra
|
2
|
+
class APIOperation
|
3
|
+
##
|
4
|
+
# == Delete a resource for the API
|
5
|
+
#
|
6
|
+
module Delete
|
7
|
+
module ClassMethods
|
8
|
+
##
|
9
|
+
# Delete an API Resource
|
10
|
+
#
|
11
|
+
# @param [String] id for the request
|
12
|
+
# @param [Hash] Additional options for the request
|
13
|
+
#
|
14
|
+
# @return [FatZebra::Object] response from the API
|
15
|
+
def delete(id, options = {})
|
16
|
+
response = request(:delete, "#{resource_path}/#{id}", options)
|
17
|
+
initialize_from(response)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# Delete an API Resources
|
23
|
+
#
|
24
|
+
# @param [Hash] Additional options for the request
|
25
|
+
#
|
26
|
+
# @return [FatZebra::Object] response from the API
|
27
|
+
def destroy(options = {})
|
28
|
+
response = request(:delete, "#{resource_path}/#{id}", {}, options)
|
29
|
+
update_from(response)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.included(base)
|
33
|
+
base.extend(ClassMethods)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module FatZebra
|
2
|
+
class APIOperation
|
3
|
+
##
|
4
|
+
# == Find a resource for the API
|
5
|
+
#
|
6
|
+
module Find
|
7
|
+
|
8
|
+
##
|
9
|
+
# Find an API Resource
|
10
|
+
#
|
11
|
+
# @param [String] id for the request
|
12
|
+
# @param [Hash] params for the request
|
13
|
+
# @param [Hash] Additional options for the request
|
14
|
+
#
|
15
|
+
# @return [FatZebra::Object] response from the API
|
16
|
+
def find(id, params = {}, options = {})
|
17
|
+
response = request(:get, "#{resource_path}/#{id}", params, options)
|
18
|
+
initialize_from(response)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module FatZebra
|
2
|
+
class APIOperation
|
3
|
+
##
|
4
|
+
# == Save (create or update) a resource for the API
|
5
|
+
#
|
6
|
+
module Save
|
7
|
+
module ClassMethods
|
8
|
+
|
9
|
+
##
|
10
|
+
# Create an API Resource and validate the params for the API.
|
11
|
+
#
|
12
|
+
# @param [Hash] params for the request
|
13
|
+
# @param [Hash] Additional options for the request
|
14
|
+
#
|
15
|
+
# @return [FatZebra::Object] response from the API
|
16
|
+
def create(params = {}, options = {})
|
17
|
+
valid!(params, :create)
|
18
|
+
|
19
|
+
response = request(:post, resource_path, params, options)
|
20
|
+
initialize_from(response)
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Update an API Resource and validate params for the API
|
25
|
+
#
|
26
|
+
# @param [String] id for the request
|
27
|
+
# @param [Hash] params for the request
|
28
|
+
# @param [Hash] Additional options for the request
|
29
|
+
#
|
30
|
+
# @return [FatZebra::Object] response from the API
|
31
|
+
def update(id, params = {}, options = {})
|
32
|
+
valid!(params, :update)
|
33
|
+
|
34
|
+
response = request(:put, "#{resource_path}/#{id}", params, options)
|
35
|
+
initialize_from(response)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# Create or Update an API Resource
|
42
|
+
#
|
43
|
+
# @param [Hash] params for the request
|
44
|
+
# @param [Hash] Additional options for the request
|
45
|
+
#
|
46
|
+
# @return [FatZebra::Object] response from the API
|
47
|
+
def save(params = {}, options = {})
|
48
|
+
path = singleton_methods.include?(:id) ? "#{resource_path}/#{id}" : resource_path
|
49
|
+
method = singleton_methods.include?(:id) ? :put : :post
|
50
|
+
|
51
|
+
response = request(method, path, to_hash.merge(params), options)
|
52
|
+
update_from(response)
|
53
|
+
end
|
54
|
+
alias update save
|
55
|
+
|
56
|
+
def self.included(base)
|
57
|
+
base.extend(ClassMethods)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module FatZebra
|
2
|
+
class APIOperation
|
3
|
+
##
|
4
|
+
# == Search resources for the API
|
5
|
+
#
|
6
|
+
module Search
|
7
|
+
|
8
|
+
##
|
9
|
+
# Default params for the API
|
10
|
+
DEFAULT_PARAMS = {
|
11
|
+
offets: 0,
|
12
|
+
limit: 10
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
##
|
16
|
+
# Search for API Resources
|
17
|
+
#
|
18
|
+
# @param [Hash] params for the request
|
19
|
+
# @param [Hash] Additional options for the request
|
20
|
+
#
|
21
|
+
# @return [FatZebra::Object] response from the API
|
22
|
+
def search(params = {}, options = {})
|
23
|
+
params = DEFAULT_PARAMS.merge(params)
|
24
|
+
params = Util.format_dates_in_hash(params)
|
25
|
+
|
26
|
+
response = request(:get, resource_path, params, options)
|
27
|
+
initialize_from(response)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module FatZebra
|
2
|
+
class APIOperation
|
3
|
+
##
|
4
|
+
# == Void a resource for the API
|
5
|
+
#
|
6
|
+
module Void
|
7
|
+
module ClassMethods
|
8
|
+
|
9
|
+
##
|
10
|
+
# Void an API Resource and validate params for the API
|
11
|
+
#
|
12
|
+
# @param [String] id for the request
|
13
|
+
# @param [Hash] params for the request
|
14
|
+
# @param [Hash] Additional options for the request
|
15
|
+
#
|
16
|
+
# @return [FatZebra::Object] response from the API
|
17
|
+
def void(id, params = {}, options = {})
|
18
|
+
valid!(params, :void)
|
19
|
+
|
20
|
+
params = {
|
21
|
+
id: id
|
22
|
+
}.merge(params)
|
23
|
+
|
24
|
+
response = request(:post, "#{resource_path}/void", params, options)
|
25
|
+
initialize_from(response)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# Void an API Resource
|
32
|
+
#
|
33
|
+
# @param [Hash] params for the request
|
34
|
+
# @param [Hash] Additional options for the request
|
35
|
+
#
|
36
|
+
# @return [FatZebra::Object] response from the API
|
37
|
+
def void(params = {}, options = {})
|
38
|
+
params = {
|
39
|
+
id: id
|
40
|
+
}.merge(params)
|
41
|
+
|
42
|
+
response = request(:post, "#{resource_path}/void", params, options)
|
43
|
+
update_from(response)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.included(base)
|
47
|
+
base.extend(ClassMethods)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
module FatZebra
|
2
|
+
##
|
3
|
+
# == FatZebra \API \Resource
|
4
|
+
#
|
5
|
+
# Define the API requests methods
|
6
|
+
class APIResource < FatZebraObject
|
7
|
+
|
8
|
+
##
|
9
|
+
# @return [String] resource name
|
10
|
+
def resource_name
|
11
|
+
self.class.resource_name
|
12
|
+
end
|
13
|
+
|
14
|
+
##
|
15
|
+
# @return [String] resource path
|
16
|
+
def resource_path(path = nil)
|
17
|
+
self.class.resource_path(path)
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
# Send a request to the API
|
22
|
+
#
|
23
|
+
# @param [Symbol] method for the request
|
24
|
+
# @param [String] endpoint for the request
|
25
|
+
# @param [Hash] options
|
26
|
+
# @param [Hash] Payload
|
27
|
+
#
|
28
|
+
# @return [Hash] response
|
29
|
+
# @raise [FatZebra::RequestError] if the request is invalid
|
30
|
+
def request(method, resource_path, payload = {}, options = {})
|
31
|
+
self.class.request(method, resource_path, payload, options)
|
32
|
+
end
|
33
|
+
|
34
|
+
class << self
|
35
|
+
|
36
|
+
##
|
37
|
+
# @return [String] resource path
|
38
|
+
def resource_path(path = nil)
|
39
|
+
"/#{configurations.api_version}/#{path || @resource_name || CGI.escape(resource_name)}"
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# @return [String] resource name
|
44
|
+
def resource_name
|
45
|
+
Util.underscore("#{class_name}s")
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# @return [String] the class name
|
50
|
+
def class_name
|
51
|
+
name.split('::')[-1]
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# Send a request to the API
|
56
|
+
#
|
57
|
+
# @param [Symbol] method for the request
|
58
|
+
# @param [String] endpoint for the request
|
59
|
+
# @param [Hash] options
|
60
|
+
# @param [Hash] Payload
|
61
|
+
#
|
62
|
+
# @return [Hash] response
|
63
|
+
# @raise [FatZebra::RequestError] if the request is invalid
|
64
|
+
def request(method, path, payload = {}, options = {})
|
65
|
+
payload[:test] = true if configurations.test_mode
|
66
|
+
|
67
|
+
if method == :get
|
68
|
+
url_params = !payload.empty? && Util.encode_parameters(payload)
|
69
|
+
payload = nil
|
70
|
+
end
|
71
|
+
|
72
|
+
uri = build_endpoint_url(path, url_params)
|
73
|
+
|
74
|
+
request_options = Util.compact(
|
75
|
+
method: method,
|
76
|
+
url: uri.to_s,
|
77
|
+
payload: payload,
|
78
|
+
proxy: configurations.proxy,
|
79
|
+
use_ssl: configurations.http_secure
|
80
|
+
).merge(authentication).merge(headers).merge(options)
|
81
|
+
|
82
|
+
request = Request.execute(request_options)
|
83
|
+
|
84
|
+
request.body
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def build_endpoint_url(path, params = nil)
|
90
|
+
host, port = configurations.gateway.split(':')
|
91
|
+
|
92
|
+
url_params = Util.compact(
|
93
|
+
host: host,
|
94
|
+
path: path,
|
95
|
+
port: port,
|
96
|
+
query: params
|
97
|
+
)
|
98
|
+
|
99
|
+
return URI::HTTPS.build(url_params) if configurations.http_secure
|
100
|
+
URI::HTTP.build(url_params)
|
101
|
+
end
|
102
|
+
|
103
|
+
def ssl_options
|
104
|
+
return {} unless configurations.http_secure
|
105
|
+
{
|
106
|
+
ca_file: File.expand_path(File.dirname(__FILE__) + '/../../vendor/cacert.pem'),
|
107
|
+
verify_mode: OpenSSL::SSL::VERIFY_PEER
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
def authentication
|
112
|
+
{
|
113
|
+
basic_auth: {
|
114
|
+
user: configurations.username,
|
115
|
+
password: configurations.token
|
116
|
+
}
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
def headers
|
121
|
+
{
|
122
|
+
headers: {
|
123
|
+
accept: 'application/json',
|
124
|
+
content_type: 'application/json'
|
125
|
+
}
|
126
|
+
}
|
127
|
+
end
|
128
|
+
|
129
|
+
def configurations
|
130
|
+
FatZebra.configurations
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module FatZebra
|
2
|
+
##
|
3
|
+
# == FatZebra \Bank \Account
|
4
|
+
#
|
5
|
+
# Manage bank account for the API
|
6
|
+
#
|
7
|
+
# * search
|
8
|
+
# * save
|
9
|
+
#
|
10
|
+
class BankAccount < APIResource
|
11
|
+
|
12
|
+
extend FatZebra::APIOperation::Search
|
13
|
+
|
14
|
+
include FatZebra::APIOperation::Save
|
15
|
+
|
16
|
+
validates :account_name, required: true, on: :create
|
17
|
+
validates :account_number, required: true, on: :create
|
18
|
+
validates :bsb, required: true, on: :create
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module FatZebra
|
2
|
+
##
|
3
|
+
# == FatZebra \Batch
|
4
|
+
#
|
5
|
+
# Manage Batch for the API
|
6
|
+
#
|
7
|
+
# * create
|
8
|
+
# * search
|
9
|
+
# * find
|
10
|
+
# * result
|
11
|
+
#
|
12
|
+
class Batch < APIResource
|
13
|
+
@resource_name = 'batches'
|
14
|
+
|
15
|
+
extend FatZebra::APIOperation::Search
|
16
|
+
extend FatZebra::APIOperation::Find
|
17
|
+
|
18
|
+
include FatZebra::APIOperation::Save
|
19
|
+
include FatZebra::APIOperation::Delete
|
20
|
+
|
21
|
+
validates :filename, required: true, class_type: String, on: :create
|
22
|
+
validates :file, required: true, class_type: File, on: :create
|
23
|
+
validates :multipart, required: true, class_type: TrueClass, on: :create
|
24
|
+
|
25
|
+
class << self
|
26
|
+
|
27
|
+
##
|
28
|
+
# Upload a batch file
|
29
|
+
#
|
30
|
+
# @param [Hash] params for the request
|
31
|
+
# @param [Hash] Additional options for the request
|
32
|
+
#
|
33
|
+
# @return [FatZebra::Batch] response from the API
|
34
|
+
def create(params, options = {})
|
35
|
+
params[:multipart] = true
|
36
|
+
params[:content_type] = 'text/csv'
|
37
|
+
params[:file] = File.new(params.delete(:path)) if params.key?(:path)
|
38
|
+
|
39
|
+
super(params, options)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Return result from the batch
|
46
|
+
#
|
47
|
+
# @param [Hash] params for capture API (Optional)
|
48
|
+
# @param [Hash] options for the request, and configurations (Optional)
|
49
|
+
#
|
50
|
+
# @return [String] formated as CSV
|
51
|
+
def result(params = {}, options = {})
|
52
|
+
request(:get, "#{resource_path}/#{id}/result.csv", params, options)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module FatZebra
|
2
|
+
##
|
3
|
+
# == FatZebra \Card
|
4
|
+
#
|
5
|
+
# Manage credit card for the API
|
6
|
+
#
|
7
|
+
# * save
|
8
|
+
#
|
9
|
+
class Card < APIResource
|
10
|
+
@resource_name = 'credit_cards'
|
11
|
+
|
12
|
+
include FatZebra::APIOperation::Save
|
13
|
+
|
14
|
+
validates :card_holder, required: true, on: :create
|
15
|
+
validates :card_number, required: true, on: :create
|
16
|
+
validates :card_expiry, required: true, on: :create
|
17
|
+
validates :cvv, required: true, on: :create
|
18
|
+
|
19
|
+
validates :card_expiry, required: true, on: :update
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|