fat_zebra 2.0.13 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +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
data/lib/fat_zebra/config.rb
CHANGED
|
@@ -1,38 +1,78 @@
|
|
|
1
1
|
module FatZebra
|
|
2
|
+
##
|
|
3
|
+
# == FatZebra \Config
|
|
4
|
+
#
|
|
5
|
+
# Represent the FatZebra configuration for the API
|
|
2
6
|
class Config
|
|
3
7
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
end
|
|
8
|
+
##
|
|
9
|
+
# @return [String] Username
|
|
10
|
+
attr_accessor :username
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
##
|
|
13
|
+
# @return [String] Token
|
|
14
|
+
attr_accessor :token
|
|
15
|
+
|
|
16
|
+
##
|
|
17
|
+
# @return [String] Test mode
|
|
18
|
+
attr_accessor :test_mode
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
# @return [String] Sandbox
|
|
22
|
+
attr_accessor :sandbox
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# @return [String] Options
|
|
26
|
+
attr_accessor :options
|
|
18
27
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
##
|
|
29
|
+
# @return [String] Gateway url
|
|
30
|
+
attr_accessor :gateway
|
|
22
31
|
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
##
|
|
33
|
+
# @return [String] Proxy url
|
|
34
|
+
attr_accessor :proxy
|
|
25
35
|
|
|
26
|
-
|
|
36
|
+
##
|
|
37
|
+
# @return [String] http secure
|
|
38
|
+
attr_accessor :http_secure
|
|
39
|
+
|
|
40
|
+
##
|
|
41
|
+
# @return [String] api version
|
|
42
|
+
attr_accessor :api_version
|
|
43
|
+
|
|
44
|
+
##
|
|
45
|
+
# @param [Hash{Symbol=>Object}]
|
|
46
|
+
# Initialize and validate the configuration
|
|
47
|
+
def initialize(options = {})
|
|
48
|
+
self.token = options[:token]
|
|
49
|
+
self.username = options[:username]
|
|
50
|
+
self.gateway = options[:gateway] || 'gateway.fatzebra.com.au'
|
|
51
|
+
self.test_mode = options[:test_mode] || false
|
|
52
|
+
self.http_secure = options[:http_secure] || true
|
|
53
|
+
self.api_version = options[:api_version] || 'v1.0'
|
|
54
|
+
self.sandbox = options[:sandbox]
|
|
55
|
+
self.options = options[:options]
|
|
56
|
+
self.proxy = options[:proxy]
|
|
27
57
|
end
|
|
28
58
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
59
|
+
##
|
|
60
|
+
# validate the configuration
|
|
61
|
+
# Raise when configuration is not valid
|
|
62
|
+
# @return [Boolean] true
|
|
63
|
+
def valid!
|
|
64
|
+
%i[username token].each do |field|
|
|
65
|
+
validate_presence(field)
|
|
33
66
|
end
|
|
34
67
|
|
|
35
|
-
|
|
68
|
+
true
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
def validate_presence(field)
|
|
74
|
+
raise FatZebra::ConfigurationError, "#{field} can't be blank" if send(field).nil? || send(field).empty?
|
|
36
75
|
end
|
|
76
|
+
|
|
37
77
|
end
|
|
38
|
-
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module FatZebra
|
|
2
|
+
##
|
|
3
|
+
# == FatZebra \Customer
|
|
4
|
+
#
|
|
5
|
+
# Manage customer for the API
|
|
6
|
+
#
|
|
7
|
+
# * search
|
|
8
|
+
# * save
|
|
9
|
+
# * find
|
|
10
|
+
# * delete
|
|
11
|
+
#
|
|
12
|
+
class Customer < APIResource
|
|
13
|
+
|
|
14
|
+
extend FatZebra::APIOperation::Search
|
|
15
|
+
extend FatZebra::APIOperation::Find
|
|
16
|
+
|
|
17
|
+
include FatZebra::APIOperation::Save
|
|
18
|
+
include FatZebra::APIOperation::Delete
|
|
19
|
+
|
|
20
|
+
validates :first_name, required: true, on: :create
|
|
21
|
+
validates :last_name, required: true, on: :create
|
|
22
|
+
validates :reference, required: true, on: :create
|
|
23
|
+
validates :email, required: true, on: :create
|
|
24
|
+
validates :ip_address, required: true, on: :create
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module FatZebra
|
|
2
|
+
##
|
|
3
|
+
# == FatZebra \Direct \Credit
|
|
4
|
+
#
|
|
5
|
+
# Manage direct credit for the API
|
|
6
|
+
#
|
|
7
|
+
# * search
|
|
8
|
+
# * save
|
|
9
|
+
# * find
|
|
10
|
+
# * delete
|
|
11
|
+
#
|
|
12
|
+
class DirectCredit < APIResource
|
|
13
|
+
|
|
14
|
+
extend FatZebra::APIOperation::Find
|
|
15
|
+
extend FatZebra::APIOperation::Search
|
|
16
|
+
|
|
17
|
+
include FatZebra::APIOperation::Save
|
|
18
|
+
include FatZebra::APIOperation::Delete
|
|
19
|
+
|
|
20
|
+
validates :description, required: true, on: :create
|
|
21
|
+
validates :amount, required: true, class_type: Integer, on: :create
|
|
22
|
+
validates :bsb, required: true, on: :create
|
|
23
|
+
validates :account_name, required: true, on: :create
|
|
24
|
+
validates :account_number, required: true, on: :create
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module FatZebra
|
|
2
|
+
##
|
|
3
|
+
# == FatZebra \Direct \Debit
|
|
4
|
+
#
|
|
5
|
+
# Manage direct debit for the API
|
|
6
|
+
#
|
|
7
|
+
# * search
|
|
8
|
+
# * save
|
|
9
|
+
# * find
|
|
10
|
+
# * delete
|
|
11
|
+
#
|
|
12
|
+
class DirectDebit < APIResource
|
|
13
|
+
|
|
14
|
+
extend FatZebra::APIOperation::Find
|
|
15
|
+
extend FatZebra::APIOperation::Search
|
|
16
|
+
|
|
17
|
+
include FatZebra::APIOperation::Save
|
|
18
|
+
include FatZebra::APIOperation::Delete
|
|
19
|
+
|
|
20
|
+
validates :description, required: true, on: :create
|
|
21
|
+
validates :amount, required: true, class_type: Integer, on: :create
|
|
22
|
+
validates :bsb, required: true, on: :create
|
|
23
|
+
validates :account_name, required: true, on: :create
|
|
24
|
+
validates :account_number, required: true, on: :create
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
data/lib/fat_zebra/errors.rb
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
module FatZebra
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
end
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# Configuration Error
|
|
5
|
+
class ConfigurationError < StandardError; end
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Request to API Error
|
|
9
|
+
class RequestError < StandardError; end
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
# Validations for the request
|
|
13
|
+
class RequestValidationError < StandardError; end
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
# Method unknown for the request
|
|
17
|
+
class UnknownRequestMethod < StandardError; end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
module FatZebra
|
|
2
|
+
##
|
|
3
|
+
# == FatZebra \Object
|
|
4
|
+
#
|
|
5
|
+
# Define the API objects
|
|
6
|
+
class FatZebraObject
|
|
7
|
+
extend Validation
|
|
8
|
+
|
|
9
|
+
##
|
|
10
|
+
# @return [Hash] JSON parsed response
|
|
11
|
+
attr_reader :raw
|
|
12
|
+
|
|
13
|
+
##
|
|
14
|
+
# @return [Hash] JSON parsed response
|
|
15
|
+
attr_reader :data
|
|
16
|
+
|
|
17
|
+
attr_reader :successful
|
|
18
|
+
alias successful? successful
|
|
19
|
+
|
|
20
|
+
attr_reader :errors
|
|
21
|
+
|
|
22
|
+
class << self
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# Initialize from the API response
|
|
26
|
+
#
|
|
27
|
+
# @return [FatZebra::FatZebraObject]
|
|
28
|
+
def initialize_from(response)
|
|
29
|
+
object = new
|
|
30
|
+
|
|
31
|
+
object.load_response_api(response.is_a?(Hash) ? response : JSON.parse(response))
|
|
32
|
+
|
|
33
|
+
if object.raw['response']
|
|
34
|
+
if object.raw['response'].is_a?(Array)
|
|
35
|
+
object.raw['response'].each { |response_object| object.add_data(initialize_from(response_object)) }
|
|
36
|
+
else
|
|
37
|
+
object.update_attributes(object.raw['response'])
|
|
38
|
+
end
|
|
39
|
+
else
|
|
40
|
+
object.update_attributes(object.raw)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
object
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
##
|
|
49
|
+
# Initialize and create accessor for values
|
|
50
|
+
#
|
|
51
|
+
# @params [Hash] values
|
|
52
|
+
def initialize(values = {})
|
|
53
|
+
@data = []
|
|
54
|
+
@values = {}
|
|
55
|
+
|
|
56
|
+
update_attributes(values)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
##
|
|
60
|
+
# Update the object based on the response from the API
|
|
61
|
+
# Remove and new acessor
|
|
62
|
+
#
|
|
63
|
+
# @param [Hash] response
|
|
64
|
+
#
|
|
65
|
+
# @return [FatZebra::FatZebraObject]
|
|
66
|
+
def update_from(response)
|
|
67
|
+
load_response_api(response.is_a?(Hash) ? response : JSON.parse(response))
|
|
68
|
+
|
|
69
|
+
# attributes to remove
|
|
70
|
+
(@values.keys - raw['response'].keys).each { |key| remove_accessor(key) }
|
|
71
|
+
|
|
72
|
+
update_attributes(raw['response'])
|
|
73
|
+
|
|
74
|
+
self
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
##
|
|
78
|
+
# get attribute value
|
|
79
|
+
def [](key)
|
|
80
|
+
@values[key.to_sym]
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
##
|
|
84
|
+
# set attribute value
|
|
85
|
+
def []=(key, value)
|
|
86
|
+
send(:"#{key}=", value)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
##
|
|
90
|
+
# @return [Array] all the keys
|
|
91
|
+
def keys
|
|
92
|
+
@values.keys
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
##
|
|
96
|
+
# @return [Hash] values to hash
|
|
97
|
+
def to_hash
|
|
98
|
+
@values
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
##
|
|
102
|
+
# @return [JSON] values to JSON
|
|
103
|
+
def to_json
|
|
104
|
+
JSON.generate(@values)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
##
|
|
108
|
+
# Update the attribute and add accessor for new attributes
|
|
109
|
+
#
|
|
110
|
+
# @param [Hash] values
|
|
111
|
+
def update_attributes(attributes)
|
|
112
|
+
attributes.each do |(key, value)|
|
|
113
|
+
add_accessor(key, value)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
##
|
|
118
|
+
# Load the root components for the API response
|
|
119
|
+
#
|
|
120
|
+
# @param [Hash] values
|
|
121
|
+
def load_response_api(response)
|
|
122
|
+
@raw = response
|
|
123
|
+
@successful = response['successful']
|
|
124
|
+
@errors = response['errors']
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
##
|
|
128
|
+
# Add data for sub-object
|
|
129
|
+
#
|
|
130
|
+
# @param [Object] data
|
|
131
|
+
def add_data(data)
|
|
132
|
+
@data << data
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
protected
|
|
136
|
+
|
|
137
|
+
def inspect
|
|
138
|
+
id_string = respond_to?(:id) && !id.nil? ? " id=#{id}" : ''
|
|
139
|
+
"#<#{self.class}:0x#{object_id.to_s(16)}#{id_string}> JSON: " + JSON.pretty_generate(@values)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def method_missing(name, *args)
|
|
143
|
+
super unless name.to_s.end_with?('=')
|
|
144
|
+
|
|
145
|
+
attribute = name.to_s[0...-1].to_sym
|
|
146
|
+
value = args.first
|
|
147
|
+
|
|
148
|
+
add_accessor(attribute, value)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
private
|
|
152
|
+
|
|
153
|
+
def add_accessors(keys, payload = raw)
|
|
154
|
+
keys.each do |key|
|
|
155
|
+
add_accessor(key, payload[key])
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def add_accessor(name, value)
|
|
160
|
+
@values[name] = value
|
|
161
|
+
|
|
162
|
+
define_singleton_method(name) { @values[name] }
|
|
163
|
+
define_singleton_method(:"#{name}=") do |v|
|
|
164
|
+
@values[name] = v
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
define_singleton_method(:"#{name}?") { value } if [FalseClass, TrueClass].include?(value.class)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def remove_accessor(name)
|
|
171
|
+
@values.delete(name)
|
|
172
|
+
|
|
173
|
+
singleton_class.class_eval { remove_method name.to_sym } if singleton_methods.include?(name.to_sym)
|
|
174
|
+
singleton_class.class_eval { remove_method "#{name}=".to_sym } if singleton_methods.include?("#{name}=".to_sym)
|
|
175
|
+
singleton_class.class_eval { remove_method "#{name}?".to_sym } if singleton_methods.include?("#{name}?".to_sym)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
end
|
|
179
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module FatZebra
|
|
2
|
+
##
|
|
3
|
+
# == FatZebra \Information
|
|
4
|
+
#
|
|
5
|
+
# Manage information for the API
|
|
6
|
+
#
|
|
7
|
+
# * ping
|
|
8
|
+
#
|
|
9
|
+
class Information < APIResource
|
|
10
|
+
class << self
|
|
11
|
+
|
|
12
|
+
##
|
|
13
|
+
# Ping the API
|
|
14
|
+
#
|
|
15
|
+
# @param [String] echo param
|
|
16
|
+
#
|
|
17
|
+
# @return [FatZebra::Information] response
|
|
18
|
+
def ping(nonce = SecureRandom.hex)
|
|
19
|
+
response = request(:get, '/ping', echo: nonce)
|
|
20
|
+
initialize_from(response)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
module FatZebra
|
|
2
|
+
##
|
|
3
|
+
# == FatZebra \Payment \Plan
|
|
4
|
+
#
|
|
5
|
+
# Manage payment plan for the API
|
|
6
|
+
#
|
|
7
|
+
# * save
|
|
8
|
+
# * find
|
|
9
|
+
# * delete
|
|
10
|
+
# * suspend!
|
|
11
|
+
# * active!
|
|
12
|
+
#
|
|
13
|
+
class PaymentPlan < APIResource
|
|
14
|
+
|
|
15
|
+
extend FatZebra::APIOperation::Find
|
|
16
|
+
|
|
17
|
+
include FatZebra::APIOperation::Save
|
|
18
|
+
include FatZebra::APIOperation::Delete
|
|
19
|
+
|
|
20
|
+
validates :payment_method, required: true, on: :create
|
|
21
|
+
validates :customer, required: true, on: :create
|
|
22
|
+
validates :reference, required: true, on: :create
|
|
23
|
+
validates :setup_fee, required: true, on: :create
|
|
24
|
+
validates :amount, required: true, on: :create
|
|
25
|
+
validates :start_date, required: true, on: :create
|
|
26
|
+
validates :frequency, required: true, on: :create
|
|
27
|
+
validates :anniversary, required: true, on: :create
|
|
28
|
+
validates :total_count, required: true, on: :create
|
|
29
|
+
validates :total_amount, required: true, on: :create
|
|
30
|
+
|
|
31
|
+
##
|
|
32
|
+
# Suspend a payment plan
|
|
33
|
+
#
|
|
34
|
+
# @param [Hash] params
|
|
35
|
+
# @param [Hash] options for the request, and configurations (Optional)
|
|
36
|
+
#
|
|
37
|
+
# @return [FatZebra::PaymentPlan]
|
|
38
|
+
def suspend!(params = {}, options = {})
|
|
39
|
+
params = {
|
|
40
|
+
new_status: 'Suspended'
|
|
41
|
+
}.merge(params)
|
|
42
|
+
|
|
43
|
+
save(params, options)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
##
|
|
47
|
+
# Activate a payment plan
|
|
48
|
+
#
|
|
49
|
+
# @param [Hash] params
|
|
50
|
+
# @param [Hash] options for the request, and configurations (Optional)
|
|
51
|
+
#
|
|
52
|
+
# @return [FatZebra::PaymentPlan]
|
|
53
|
+
def active!(params = {}, options = {})
|
|
54
|
+
params = {
|
|
55
|
+
new_status: 'Active'
|
|
56
|
+
}.merge(params)
|
|
57
|
+
|
|
58
|
+
save(params, options)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
module FatZebra
|
|
2
|
+
##
|
|
3
|
+
# == FatZebra \Purchase
|
|
4
|
+
#
|
|
5
|
+
# Manage purchase for the API
|
|
6
|
+
#
|
|
7
|
+
# * search
|
|
8
|
+
# * save
|
|
9
|
+
# * find
|
|
10
|
+
# * void
|
|
11
|
+
# * settlement
|
|
12
|
+
# * refund
|
|
13
|
+
# * capture
|
|
14
|
+
#
|
|
15
|
+
class Purchase < APIResource
|
|
16
|
+
|
|
17
|
+
extend FatZebra::APIOperation::Find
|
|
18
|
+
extend FatZebra::APIOperation::Search
|
|
19
|
+
|
|
20
|
+
include FatZebra::APIOperation::Save
|
|
21
|
+
include FatZebra::APIOperation::Void
|
|
22
|
+
|
|
23
|
+
validates :card_number, required: { unless: %i[card_token wallet] }, on: :create
|
|
24
|
+
validates :card_token, required: { unless: %i[card_number wallet] }, on: :create
|
|
25
|
+
validates :card_expiry, required: { unless: %i[card_token wallet] }, on: :create
|
|
26
|
+
validates :amount, required: true, class_type: Integer, on: :create
|
|
27
|
+
validates :reference, required: true, on: :create
|
|
28
|
+
validates :customer_ip, required: true, on: :create
|
|
29
|
+
|
|
30
|
+
validates :from, required: true, on: :settlement
|
|
31
|
+
validates :to, required: true, on: :settlement
|
|
32
|
+
|
|
33
|
+
class << self
|
|
34
|
+
|
|
35
|
+
##
|
|
36
|
+
# Create a payment plan
|
|
37
|
+
# Default currency to AUD
|
|
38
|
+
#
|
|
39
|
+
# @param [Hash] params
|
|
40
|
+
# @param [Hash] options for the request, and configurations (Optional)
|
|
41
|
+
#
|
|
42
|
+
# @return [FatZebra::PaymentPlan]
|
|
43
|
+
def create(params, options = {})
|
|
44
|
+
params[:currency] ||= 'AUD'
|
|
45
|
+
|
|
46
|
+
super(params, options)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
##
|
|
50
|
+
# Return all the settlements
|
|
51
|
+
#
|
|
52
|
+
# @param [Hash] params (from and to are date required)
|
|
53
|
+
# @param [Hash] options for the request, and configurations (Optional)
|
|
54
|
+
#
|
|
55
|
+
# @return [FatZebra::Purchase]
|
|
56
|
+
def settlement(params = {}, options = {})
|
|
57
|
+
valid!(params, :settlement)
|
|
58
|
+
|
|
59
|
+
params = Util.format_dates_in_hash(params)
|
|
60
|
+
|
|
61
|
+
response = request(:get, "#{resource_path}/settlement", params, options)
|
|
62
|
+
initialize_from(response)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
##
|
|
68
|
+
# Refunds the current purchase
|
|
69
|
+
#
|
|
70
|
+
# @param [Hash] params for refund API (Optional)
|
|
71
|
+
# @param [Hash] options for the request, and configurations (Optional)
|
|
72
|
+
#
|
|
73
|
+
# @return [FatZebra::Refund] object
|
|
74
|
+
def refund(params = {}, options = {})
|
|
75
|
+
Refund.create({
|
|
76
|
+
transaction_id: id,
|
|
77
|
+
amount: amount,
|
|
78
|
+
reference: reference
|
|
79
|
+
}.merge(params), options)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
##
|
|
83
|
+
# Captures an authorization
|
|
84
|
+
#
|
|
85
|
+
# @param [Hash] params for capture API (Optional)
|
|
86
|
+
# @param [Hash] options for the request, and configurations (Optional)
|
|
87
|
+
#
|
|
88
|
+
# @return [Response] Purchase response object
|
|
89
|
+
def capture(params = {}, options = {})
|
|
90
|
+
params = {
|
|
91
|
+
amount: amount
|
|
92
|
+
}.merge(params)
|
|
93
|
+
|
|
94
|
+
response = request(:post, resource_path("purchases/#{id}/capture"), params, options)
|
|
95
|
+
update_from(response)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end
|
|
99
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module FatZebra
|
|
2
|
+
##
|
|
3
|
+
# == FatZebra \Refund
|
|
4
|
+
#
|
|
5
|
+
# Manage refund for the API
|
|
6
|
+
#
|
|
7
|
+
# * search
|
|
8
|
+
# * save
|
|
9
|
+
# * find
|
|
10
|
+
# * void
|
|
11
|
+
#
|
|
12
|
+
class Refund < APIResource
|
|
13
|
+
|
|
14
|
+
extend FatZebra::APIOperation::Find
|
|
15
|
+
extend FatZebra::APIOperation::Search
|
|
16
|
+
|
|
17
|
+
include FatZebra::APIOperation::Save
|
|
18
|
+
include FatZebra::APIOperation::Void
|
|
19
|
+
|
|
20
|
+
validates :transaction_id, required: true, on: :create
|
|
21
|
+
validates :amount, required: true, on: :create
|
|
22
|
+
validates :reference, required: true, on: :create
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module FatZebra
|
|
2
|
+
##
|
|
3
|
+
# == FatZebra \Request \Multipart \Epilogue
|
|
4
|
+
#
|
|
5
|
+
# Add the epilogue to the multipart
|
|
6
|
+
class Request
|
|
7
|
+
module Multipart
|
|
8
|
+
class Epilogue
|
|
9
|
+
include Part
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
@io = StringIO.new(footer)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def footer
|
|
18
|
+
"--#{boundary}--#{LINE_BREAK}"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module FatZebra
|
|
2
|
+
##
|
|
3
|
+
# == FatZebra \Request \Multipart \FileIO
|
|
4
|
+
#
|
|
5
|
+
# Add file to the multipart
|
|
6
|
+
class Request
|
|
7
|
+
module Multipart
|
|
8
|
+
class FileIO
|
|
9
|
+
include Part
|
|
10
|
+
|
|
11
|
+
attr_reader :length, :stream
|
|
12
|
+
|
|
13
|
+
def initialize(options)
|
|
14
|
+
@filename = options[:filename]
|
|
15
|
+
@file = options[:file]
|
|
16
|
+
@content_type = options[:content_type]
|
|
17
|
+
@options = options
|
|
18
|
+
@file_size = File.size(@file)
|
|
19
|
+
@footer = LINE_BREAK
|
|
20
|
+
@length = header.bytesize + @file_size + @footer.length
|
|
21
|
+
@io = Stream.new(StringIO.new(header), @file, StringIO.new(@footer))
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def header
|
|
25
|
+
part = []
|
|
26
|
+
part << "--#{boundary}"
|
|
27
|
+
part << "Content-Disposition: form-data; name=\"#{@filename}\"; filename=\"#{@filename}\""
|
|
28
|
+
part << "Content-Length: #{@size}"
|
|
29
|
+
part << "Content-Type: #{@content_type}"
|
|
30
|
+
part << 'Content-Transfer-Encoding: binary'
|
|
31
|
+
part << LINE_BREAK
|
|
32
|
+
|
|
33
|
+
part.join(LINE_BREAK)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module FatZebra
|
|
2
|
+
##
|
|
3
|
+
# == FatZebra \Request \Multipart \Param
|
|
4
|
+
#
|
|
5
|
+
# Add param to the multipart
|
|
6
|
+
class Request
|
|
7
|
+
module Multipart
|
|
8
|
+
class Param
|
|
9
|
+
include Part
|
|
10
|
+
|
|
11
|
+
def initialize(name, value)
|
|
12
|
+
@name = name
|
|
13
|
+
@value = value
|
|
14
|
+
@io = StringIO.new(part)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def length
|
|
18
|
+
part.bytesize
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def part
|
|
24
|
+
part = []
|
|
25
|
+
part << "--#{boundary}"
|
|
26
|
+
part << "Content-Disposition: form-data; name=\"#{@name}\""
|
|
27
|
+
part << ''
|
|
28
|
+
part << @value
|
|
29
|
+
|
|
30
|
+
part.join(LINE_BREAK)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|