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.
Files changed (233) hide show
  1. checksums.yaml +5 -13
  2. data/.rubocop.yml +42 -0
  3. data/.travis.yml +9 -2
  4. data/Gemfile +1 -1
  5. data/{README.markdown → README.md} +19 -20
  6. data/Rakefile +2 -12
  7. data/fat_zebra.gemspec +27 -0
  8. data/lib/fat_zebra/api_operation/delete.rb +38 -0
  9. data/lib/fat_zebra/api_operation/find.rb +23 -0
  10. data/lib/fat_zebra/api_operation/save.rb +62 -0
  11. data/lib/fat_zebra/api_operation/search.rb +32 -0
  12. data/lib/fat_zebra/api_operation/void.rb +52 -0
  13. data/lib/fat_zebra/api_resource.rb +135 -0
  14. data/lib/fat_zebra/bank_account.rb +21 -0
  15. data/lib/fat_zebra/batch.rb +56 -0
  16. data/lib/fat_zebra/card.rb +22 -0
  17. data/lib/fat_zebra/config.rb +65 -25
  18. data/lib/fat_zebra/customer.rb +27 -0
  19. data/lib/fat_zebra/direct_credit.rb +27 -0
  20. data/lib/fat_zebra/direct_debit.rb +27 -0
  21. data/lib/fat_zebra/errors.rb +18 -4
  22. data/lib/fat_zebra/fat_zebra_object.rb +179 -0
  23. data/lib/fat_zebra/information.rb +25 -0
  24. data/lib/fat_zebra/payment_plan.rb +62 -0
  25. data/lib/fat_zebra/purchase.rb +99 -0
  26. data/lib/fat_zebra/refund.rb +25 -0
  27. data/lib/fat_zebra/request/multipart/epilogue.rb +23 -0
  28. data/lib/fat_zebra/request/multipart/file_io.rb +40 -0
  29. data/lib/fat_zebra/request/multipart/param.rb +37 -0
  30. data/lib/fat_zebra/request/multipart/part.rb +28 -0
  31. data/lib/fat_zebra/request/multipart/stream.rb +55 -0
  32. data/lib/fat_zebra/request.rb +162 -0
  33. data/lib/fat_zebra/util.rb +70 -0
  34. data/lib/fat_zebra/validation.rb +47 -0
  35. data/lib/fat_zebra/version.rb +1 -1
  36. data/lib/fat_zebra/web_hook.rb +23 -0
  37. data/lib/fat_zebra.rb +51 -55
  38. data/spec/cassettes/FatZebra_BankAccount/_create/1_1_1.yml +57 -0
  39. data/spec/cassettes/FatZebra_BankAccount/_create/1_1_2.yml +57 -0
  40. data/spec/cassettes/FatZebra_BankAccount/_create/validations/1_1_3_1.yml +57 -0
  41. data/spec/cassettes/FatZebra_BankAccount/_search/1_2_1.yml +172 -0
  42. data/spec/cassettes/FatZebra_BankAccount/_search/1_2_2.yml +172 -0
  43. data/spec/cassettes/FatZebra_BankAccount/_search/1_2_3.yml +172 -0
  44. data/spec/cassettes/FatZebra_Batch/_create/1_1_1.yml +58 -0
  45. data/spec/cassettes/FatZebra_Batch/_create/1_1_2.yml +58 -0
  46. data/spec/cassettes/FatZebra_Batch/_create/validations/1_1_3_1.yml +57 -0
  47. data/spec/cassettes/FatZebra_Batch/_create/with_file/1_1_1_1.yml +58 -0
  48. data/spec/cassettes/FatZebra_Batch/_create/with_file/1_1_1_2.yml +58 -0
  49. data/spec/cassettes/FatZebra_Batch/_create/with_path/1_1_2_1.yml +58 -0
  50. data/spec/cassettes/FatZebra_Batch/_create/with_path/1_1_2_2.yml +58 -0
  51. data/spec/cassettes/FatZebra_Batch/_find/1_2_1.yml +109 -0
  52. data/spec/cassettes/FatZebra_Batch/_find/1_2_2.yml +109 -0
  53. data/spec/cassettes/FatZebra_Batch/_result/1_4_1.yml +160 -0
  54. data/spec/cassettes/FatZebra_Batch/_search/1_3_1.yml +54 -0
  55. data/spec/cassettes/FatZebra_Batch/_search/1_3_2.yml +54 -0
  56. data/spec/cassettes/FatZebra_Batch/_search/1_3_3.yml +54 -0
  57. data/spec/cassettes/FatZebra_Card/_create/1_1_1.yml +55 -0
  58. data/spec/cassettes/FatZebra_Card/_create/1_1_2.yml +55 -0
  59. data/spec/cassettes/FatZebra_Card/_create/1_1_3.yml +55 -0
  60. data/spec/cassettes/FatZebra_Card/_create/1_1_4.yml +55 -0
  61. data/spec/cassettes/FatZebra_Card/_create/1_1_5.yml +55 -0
  62. data/spec/cassettes/FatZebra_Card/_create/1_1_6.yml +55 -0
  63. data/spec/cassettes/FatZebra_Card/_create/validations/1_1_7_1.yml +56 -0
  64. data/spec/cassettes/FatZebra_Card/_update/1_2_1.yml +105 -0
  65. data/spec/cassettes/FatZebra_Card/_update/1_2_2.yml +105 -0
  66. data/spec/cassettes/FatZebra_Card/_update/1_2_3.yml +105 -0
  67. data/spec/cassettes/FatZebra_Card/_update/validations/1_2_4_1.yml +55 -0
  68. data/spec/cassettes/FatZebra_Customer/_create/1_1_1.yml +59 -0
  69. data/spec/cassettes/FatZebra_Customer/_create/1_1_2.yml +59 -0
  70. data/spec/cassettes/FatZebra_Customer/_create/1_1_3.yml +59 -0
  71. data/spec/cassettes/FatZebra_Customer/_create/1_1_4.yml +59 -0
  72. data/spec/cassettes/FatZebra_Customer/_create/1_1_5.yml +59 -0
  73. data/spec/cassettes/FatZebra_Customer/_create/1_1_6.yml +59 -0
  74. data/spec/cassettes/FatZebra_Customer/_create/validations/1_1_7_1.yml +56 -0
  75. data/spec/cassettes/FatZebra_Customer/_delete/1_4_1.yml +113 -0
  76. data/spec/cassettes/FatZebra_Customer/_delete/1_5_1.yml +113 -0
  77. data/spec/cassettes/FatZebra_Customer/_find/1_2_1.yml +111 -0
  78. data/spec/cassettes/FatZebra_Customer/_find/1_2_2.yml +111 -0
  79. data/spec/cassettes/FatZebra_Customer/_find/1_3_1.yml +111 -0
  80. data/spec/cassettes/FatZebra_Customer/_find/1_3_2.yml +111 -0
  81. data/spec/cassettes/FatZebra_Customer/_search/1_2_1.yml +56 -0
  82. data/spec/cassettes/FatZebra_Customer/_search/1_2_2.yml +56 -0
  83. data/spec/cassettes/FatZebra_Customer/_search/1_2_3.yml +56 -0
  84. data/spec/cassettes/FatZebra_Customer/_update/1_3_1.yml +114 -0
  85. data/spec/cassettes/FatZebra_Customer/_update/1_3_2.yml +114 -0
  86. data/spec/cassettes/FatZebra_Customer/_update/1_4_1.yml +114 -0
  87. data/spec/cassettes/FatZebra_Customer/_update/1_4_2.yml +114 -0
  88. data/spec/cassettes/FatZebra_DirectCredit/_create/1_1_1.yml +56 -0
  89. data/spec/cassettes/FatZebra_DirectCredit/_create/1_1_2.yml +56 -0
  90. data/spec/cassettes/FatZebra_DirectCredit/_create/1_1_3.yml +56 -0
  91. data/spec/cassettes/FatZebra_DirectCredit/_create/1_1_4.yml +56 -0
  92. data/spec/cassettes/FatZebra_DirectCredit/_create/validations/1_1_5_1.yml +59 -0
  93. data/spec/cassettes/FatZebra_DirectCredit/_delete/1_4_1.yml +109 -0
  94. data/spec/cassettes/FatZebra_DirectCredit/_find/1_2_1.yml +107 -0
  95. data/spec/cassettes/FatZebra_DirectCredit/_find/1_2_2.yml +107 -0
  96. data/spec/cassettes/FatZebra_DirectCredit/_search/1_3_1.yml +160 -0
  97. data/spec/cassettes/FatZebra_DirectCredit/_search/1_3_2.yml +160 -0
  98. data/spec/cassettes/FatZebra_DirectDebit/_create/1_1_1.yml +56 -0
  99. data/spec/cassettes/FatZebra_DirectDebit/_create/1_1_2.yml +56 -0
  100. data/spec/cassettes/FatZebra_DirectDebit/_create/1_1_3.yml +56 -0
  101. data/spec/cassettes/FatZebra_DirectDebit/_create/1_1_4.yml +56 -0
  102. data/spec/cassettes/FatZebra_DirectDebit/_create/validations/1_1_5_1.yml +59 -0
  103. data/spec/cassettes/FatZebra_DirectDebit/_delete/1_4_1.yml +109 -0
  104. data/spec/cassettes/FatZebra_DirectDebit/_find/1_2_1.yml +107 -0
  105. data/spec/cassettes/FatZebra_DirectDebit/_find/1_2_2.yml +107 -0
  106. data/spec/cassettes/FatZebra_DirectDebit/_search/1_3_1.yml +160 -0
  107. data/spec/cassettes/FatZebra_DirectDebit/_search/1_3_2.yml +160 -0
  108. data/spec/cassettes/FatZebra_Information/_ping/1_1_1.yml +54 -0
  109. data/spec/cassettes/FatZebra_Information/_ping/1_1_2.yml +54 -0
  110. data/spec/cassettes/FatZebra_PaymentPlan/_active_/1_7_1.yml +238 -0
  111. data/spec/cassettes/FatZebra_PaymentPlan/_active_/1_7_2.yml +238 -0
  112. data/spec/cassettes/FatZebra_PaymentPlan/_active_/1_8_1.yml +238 -0
  113. data/spec/cassettes/FatZebra_PaymentPlan/_active_/1_8_2.yml +238 -0
  114. data/spec/cassettes/FatZebra_PaymentPlan/_create/1_1_1.yml +118 -0
  115. data/spec/cassettes/FatZebra_PaymentPlan/_create/1_1_2.yml +118 -0
  116. data/spec/cassettes/FatZebra_PaymentPlan/_create/1_1_3.yml +118 -0
  117. data/spec/cassettes/FatZebra_PaymentPlan/_create/validations/1_1_4_1.yml +55 -0
  118. data/spec/cassettes/FatZebra_PaymentPlan/_delete/1_5_1.yml +172 -0
  119. data/spec/cassettes/FatZebra_PaymentPlan/_destroy/1_6_1.yml +172 -0
  120. data/spec/cassettes/FatZebra_PaymentPlan/_find/1_2_1.yml +175 -0
  121. data/spec/cassettes/FatZebra_PaymentPlan/_find/1_2_2.yml +175 -0
  122. data/spec/cassettes/FatZebra_PaymentPlan/_find/1_2_3.yml +175 -0
  123. data/spec/cassettes/FatZebra_PaymentPlan/_suspend_/1_6_1.yml +178 -0
  124. data/spec/cassettes/FatZebra_PaymentPlan/_suspend_/1_6_2.yml +178 -0
  125. data/spec/cassettes/FatZebra_PaymentPlan/_suspend_/1_7_1.yml +178 -0
  126. data/spec/cassettes/FatZebra_PaymentPlan/_suspend_/1_7_2.yml +178 -0
  127. data/spec/cassettes/FatZebra_PaymentPlan/_update/1_3_1.yml +172 -0
  128. data/spec/cassettes/FatZebra_PaymentPlan/_update/1_3_2.yml +172 -0
  129. data/spec/cassettes/FatZebra_PaymentPlan/_update/1_3_3.yml +172 -0
  130. data/spec/cassettes/FatZebra_PaymentPlan/_update/1_4_1.yml +178 -0
  131. data/spec/cassettes/FatZebra_PaymentPlan/_update/1_4_2.yml +178 -0
  132. data/spec/cassettes/FatZebra_Purchase/_capture/1_5_1.yml +111 -0
  133. data/spec/cassettes/FatZebra_Purchase/_capture/1_5_2.yml +111 -0
  134. data/spec/cassettes/FatZebra_Purchase/_capture/1_6_1.yml +111 -0
  135. data/spec/cassettes/FatZebra_Purchase/_capture/1_6_2.yml +111 -0
  136. data/spec/cassettes/FatZebra_Purchase/_create/1_1_1.yml +57 -0
  137. data/spec/cassettes/FatZebra_Purchase/_create/1_1_10.yml +57 -0
  138. data/spec/cassettes/FatZebra_Purchase/_create/1_1_11.yml +57 -0
  139. data/spec/cassettes/FatZebra_Purchase/_create/1_1_12.yml +57 -0
  140. data/spec/cassettes/FatZebra_Purchase/_create/1_1_2.yml +57 -0
  141. data/spec/cassettes/FatZebra_Purchase/_create/1_1_3.yml +57 -0
  142. data/spec/cassettes/FatZebra_Purchase/_create/1_1_4.yml +57 -0
  143. data/spec/cassettes/FatZebra_Purchase/_create/1_1_5.yml +57 -0
  144. data/spec/cassettes/FatZebra_Purchase/_create/1_1_6.yml +57 -0
  145. data/spec/cassettes/FatZebra_Purchase/_create/1_1_7.yml +57 -0
  146. data/spec/cassettes/FatZebra_Purchase/_create/1_1_8.yml +57 -0
  147. data/spec/cassettes/FatZebra_Purchase/_create/1_1_9.yml +57 -0
  148. data/spec/cassettes/FatZebra_Purchase/_find/1_2_1.yml +109 -0
  149. data/spec/cassettes/FatZebra_Purchase/_find/1_2_2.yml +109 -0
  150. data/spec/cassettes/FatZebra_Purchase/_find/1_2_3.yml +109 -0
  151. data/spec/cassettes/FatZebra_Purchase/_find/1_4_1.yml +109 -0
  152. data/spec/cassettes/FatZebra_Purchase/_find/1_4_2.yml +109 -0
  153. data/spec/cassettes/FatZebra_Purchase/_find/1_4_3.yml +109 -0
  154. data/spec/cassettes/FatZebra_Purchase/_refund/1_4_1.yml +111 -0
  155. data/spec/cassettes/FatZebra_Purchase/_refund/1_4_2.yml +111 -0
  156. data/spec/cassettes/FatZebra_Purchase/_refund/1_5_1.yml +111 -0
  157. data/spec/cassettes/FatZebra_Purchase/_refund/1_5_2.yml +111 -0
  158. data/spec/cassettes/FatZebra_Purchase/_search/1_3_1.yml +170 -0
  159. data/spec/cassettes/FatZebra_Purchase/_search/1_3_2.yml +170 -0
  160. data/spec/cassettes/FatZebra_Purchase/_search/1_3_3.yml +170 -0
  161. data/spec/cassettes/FatZebra_Purchase/_search/with_data/1_3_2_1.yml +164 -0
  162. data/spec/cassettes/FatZebra_Purchase/_search/with_data/1_3_2_2.yml +165 -0
  163. data/spec/cassettes/FatZebra_Purchase/_search/with_data/1_3_2_3.yml +164 -0
  164. data/spec/cassettes/FatZebra_Purchase/_search/without_data/1_3_1_1.yml +54 -0
  165. data/spec/cassettes/FatZebra_Purchase/_search/without_data/1_3_1_2.yml +54 -0
  166. data/spec/cassettes/FatZebra_Purchase/_search/without_data/1_3_1_3.yml +54 -0
  167. data/spec/cassettes/FatZebra_Purchase/_settlement/1_8_1.yml +613 -0
  168. data/spec/cassettes/FatZebra_Purchase/_settlement/1_8_2.yml +615 -0
  169. data/spec/cassettes/FatZebra_Purchase/_settlement/1_8_3.yml +617 -0
  170. data/spec/cassettes/FatZebra_Purchase/_void/1_6_1.yml +111 -0
  171. data/spec/cassettes/FatZebra_Purchase/_void/1_6_2.yml +111 -0
  172. data/spec/cassettes/FatZebra_Purchase/_void/1_6_3.yml +111 -0
  173. data/spec/cassettes/FatZebra_Purchase/_void/1_7_1.yml +111 -0
  174. data/spec/cassettes/FatZebra_Purchase/_void/1_7_2.yml +111 -0
  175. data/spec/cassettes/FatZebra_Purchase/_void/1_7_3.yml +111 -0
  176. data/spec/cassettes/FatZebra_Refund/_create/1_1_1.yml +111 -0
  177. data/spec/cassettes/FatZebra_Refund/_create/1_1_2.yml +111 -0
  178. data/spec/cassettes/FatZebra_Refund/_create/1_1_3.yml +111 -0
  179. data/spec/cassettes/FatZebra_Refund/_create/1_1_4.yml +111 -0
  180. data/spec/cassettes/FatZebra_Refund/_create/1_1_5.yml +111 -0
  181. data/spec/cassettes/FatZebra_Refund/_create/1_1_6.yml +111 -0
  182. data/spec/cassettes/FatZebra_Refund/_create/1_1_7.yml +111 -0
  183. data/spec/cassettes/FatZebra_Refund/_create/1_1_8.yml +111 -0
  184. data/spec/cassettes/FatZebra_Refund/_create/1_1_9.yml +111 -0
  185. data/spec/cassettes/FatZebra_Refund/_find/1_2_1.yml +163 -0
  186. data/spec/cassettes/FatZebra_Refund/_find/1_2_2.yml +163 -0
  187. data/spec/cassettes/FatZebra_Refund/_search/1_3_1.yml +281 -0
  188. data/spec/cassettes/FatZebra_Refund/_search/1_3_2.yml +281 -0
  189. data/spec/cassettes/FatZebra_Refund/_void/1_4_1.yml +165 -0
  190. data/spec/cassettes/FatZebra_Refund/_void/1_4_2.yml +165 -0
  191. data/spec/cassettes/FatZebra_Refund/_void/1_4_3.yml +165 -0
  192. data/spec/cassettes/FatZebra_WebHook/_create/1_1_1.yml +57 -0
  193. data/spec/cassettes/FatZebra_WebHook/_create/1_1_2.yml +57 -0
  194. data/spec/cassettes/FatZebra_WebHook/_create/1_1_3.yml +57 -0
  195. data/spec/cassettes/FatZebra_WebHook/_create/validations/1_1_4_1.yml +56 -0
  196. data/spec/cassettes/FatZebra_WebHook/_delete/1_4_1.yml +111 -0
  197. data/spec/cassettes/FatZebra_WebHook/_search/1_2_1.yml +222 -0
  198. data/spec/cassettes/FatZebra_WebHook/_search/1_2_2.yml +224 -0
  199. data/spec/cassettes/FatZebra_WebHook/_update/1_3_1.yml +112 -0
  200. data/spec/cassettes/FatZebra_WebHook/_update/1_3_2.yml +112 -0
  201. data/spec/fixtures/batch_test.csv +4 -0
  202. data/spec/lib/fat_zebra/bank_account_spec.rb +34 -0
  203. data/spec/lib/fat_zebra/batch_spec.rb +59 -0
  204. data/spec/lib/fat_zebra/card_spec.rb +41 -0
  205. data/spec/lib/fat_zebra/config_spec.rb +52 -0
  206. data/spec/lib/fat_zebra/customer_spec.rb +53 -0
  207. data/spec/lib/fat_zebra/direct_credit_spec.rb +53 -0
  208. data/spec/lib/fat_zebra/direct_debit_spec.rb +53 -0
  209. data/spec/lib/fat_zebra/fat_zebra_object_spec.rb +116 -0
  210. data/spec/lib/fat_zebra/information_spec.rb +13 -0
  211. data/spec/lib/fat_zebra/payment_plan_spec.rb +94 -0
  212. data/spec/lib/fat_zebra/purchase_spec.rb +92 -0
  213. data/spec/lib/fat_zebra/refund_spec.rb +72 -0
  214. data/spec/lib/fat_zebra/util_spec.rb +24 -0
  215. data/spec/lib/fat_zebra/validation_spec.rb +22 -0
  216. data/spec/lib/fat_zebra/web_hook_spec.rb +50 -0
  217. data/spec/spec_helper.rb +49 -3
  218. data/spec/support/payloads.rb +43 -0
  219. metadata +238 -65
  220. data/FatZebra.gemspec +0 -31
  221. data/lib/fat_zebra/constants.rb +0 -2
  222. data/lib/fat_zebra/gateway.rb +0 -292
  223. data/lib/fat_zebra/models/base.rb +0 -33
  224. data/lib/fat_zebra/models/card.rb +0 -49
  225. data/lib/fat_zebra/models/purchase.rb +0 -185
  226. data/lib/fat_zebra/models/refund.rb +0 -46
  227. data/lib/fat_zebra/models/response.rb +0 -33
  228. data/lib/rest-client/request_ext.rb +0 -15
  229. data/spec/config_spec.rb +0 -37
  230. data/spec/gateway_spec.rb +0 -120
  231. data/spec/models/purchase_spec.rb +0 -55
  232. data/spec/models/refund_spec.rb +0 -9
  233. data/spec/models/response_spec.rb +0 -25
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MWFkOTI1MGY3NWY2YmUxN2E5ZGEzMGFjN2YxM2I0ZjI5MmRhNTA0MA==
5
- data.tar.gz: !binary |-
6
- OGExZDFlYzVkODNlYWFhZDkwY2ZkZGQ3MzE1NDRmODFjYzNjODE1NQ==
2
+ SHA1:
3
+ metadata.gz: a2d528ebf041ec5f73b61570237e3547dc3d9d45
4
+ data.tar.gz: c8b2990d36c46054972c47fe5272f21002e648b6
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ODk5MmI4ODFkZjY2NzIwYzkzMGNiOGJiM2Y2Y2I2MzcxNGJmZTA0N2YxMjJm
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
@@ -1,4 +1,11 @@
1
+ cache: bundler
1
2
  language: ruby
2
3
  rvm:
3
- - 1.9.3
4
- - 2.0.0
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
7
+ - 2.3
8
+ - 2.4
9
+ script:
10
+ - bundle exec rspec spec
11
+ - bundle exec rubocop
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in FatZebra.gemspec
4
4
  gemspec
@@ -1,18 +1,17 @@
1
1
  Ruby API Library for Fat Zebra
2
2
  ==============================
3
3
 
4
- Release 2.0.0 for API version 1.0
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.9.3, 2.0.0)
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 "TEST"
35
- config.token "TEST"
36
- config.gateway "gateway.fatzebra.com.au"
33
+ config.username = 'TEST'
34
+ config.token = 'TEST'
37
35
  end
38
36
 
39
- card_data = {
40
- number: "5123456789012346",
41
- card_holder: "Bill Simpson",
42
- expiry: "05/2023",
43
- cvv: "123"
44
- }
45
-
46
- response = FatZebra::Models::Purchase.create(10000, card_data, "ORDER-23", "203.99.87.4")
47
-
48
- if response.successful? && response.result.successful
49
- puts "Transaction ID: #{response.result.id}"
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
- abort "Error in transaction: #{response.errors}"
50
+ abort "Error in transaction: #{purchase.errors}"
52
51
  end
53
52
  ```
54
53
 
data/Rakefile CHANGED
@@ -1,18 +1,8 @@
1
- require "bundler/gem_tasks"
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 :default => :spec
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