mangopay-v4 4.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 +7 -0
- data/.gitignore +30 -0
- data/.rspec +4 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +13 -0
- data/Gemfile +2 -0
- data/LICENSE +20 -0
- data/README.md +380 -0
- data/bin/mangopay +9 -0
- data/lib/mangopay.rb +133 -0
- data/lib/mangopay/api/api.rb +9 -0
- data/lib/mangopay/api/api_methods.rb +137 -0
- data/lib/mangopay/api/auth_token_manager.rb +173 -0
- data/lib/mangopay/api/http_client.rb +325 -0
- data/lib/mangopay/api/service/bank_accounts.rb +146 -0
- data/lib/mangopay/api/service/cards.rb +152 -0
- data/lib/mangopay/api/service/client_wallets.rb +89 -0
- data/lib/mangopay/api/service/clients.rb +68 -0
- data/lib/mangopay/api/service/dispute_documents.rb +158 -0
- data/lib/mangopay/api/service/disputes.rb +187 -0
- data/lib/mangopay/api/service/e_money.rb +42 -0
- data/lib/mangopay/api/service/events.rb +47 -0
- data/lib/mangopay/api/service/hooks.rb +93 -0
- data/lib/mangopay/api/service/kyc_documents.rb +153 -0
- data/lib/mangopay/api/service/mandates.rb +142 -0
- data/lib/mangopay/api/service/oauth_tokens.rb +25 -0
- data/lib/mangopay/api/service/pay_ins.rb +260 -0
- data/lib/mangopay/api/service/pay_outs.rb +54 -0
- data/lib/mangopay/api/service/pre_authorizations.rb +69 -0
- data/lib/mangopay/api/service/refunds.rb +62 -0
- data/lib/mangopay/api/service/reports.rb +151 -0
- data/lib/mangopay/api/service/repudiations.rb +32 -0
- data/lib/mangopay/api/service/responses.rb +102 -0
- data/lib/mangopay/api/service/settlement_transfers.rb +55 -0
- data/lib/mangopay/api/service/transactions.rb +183 -0
- data/lib/mangopay/api/service/transfers.rb +54 -0
- data/lib/mangopay/api/service/ubo_declarations.rb +70 -0
- data/lib/mangopay/api/service/users.rb +163 -0
- data/lib/mangopay/api/service/wallets.rb +99 -0
- data/lib/mangopay/api/uri_provider.rb +35 -0
- data/lib/mangopay/common/json_tag_converter.rb +68 -0
- data/lib/mangopay/common/jsonifier.rb +249 -0
- data/lib/mangopay/common/log_provider.rb +34 -0
- data/lib/mangopay/common/rate_limit_interval.rb +17 -0
- data/lib/mangopay/common/read_only_fields.rb +27 -0
- data/lib/mangopay/common/response_error.rb +61 -0
- data/lib/mangopay/common/sort_direction.rb +15 -0
- data/lib/mangopay/common/sort_field.rb +13 -0
- data/lib/mangopay/common/template_url_options.rb +9 -0
- data/lib/mangopay/configuration.rb +39 -0
- data/lib/mangopay/environment.rb +66 -0
- data/lib/mangopay/model/address.rb +27 -0
- data/lib/mangopay/model/declared_ubo.rb +21 -0
- data/lib/mangopay/model/dispute_reason.rb +15 -0
- data/lib/mangopay/model/document_page_consult.rb +15 -0
- data/lib/mangopay/model/e_money.rb +18 -0
- data/lib/mangopay/model/entity/account/bank_account.rb +26 -0
- data/lib/mangopay/model/entity/account/ca_bank_account.rb +27 -0
- data/lib/mangopay/model/entity/account/gb_bank_account.rb +21 -0
- data/lib/mangopay/model/entity/account/iban_bank_account.rb +21 -0
- data/lib/mangopay/model/entity/account/other_bank_account.rb +24 -0
- data/lib/mangopay/model/entity/account/us_bank_account.rb +24 -0
- data/lib/mangopay/model/entity/card.rb +45 -0
- data/lib/mangopay/model/entity/card_registration.rb +43 -0
- data/lib/mangopay/model/entity/client.rb +63 -0
- data/lib/mangopay/model/entity/client_wallet.rb +23 -0
- data/lib/mangopay/model/entity/dispute.rb +50 -0
- data/lib/mangopay/model/entity/dispute_document.rb +29 -0
- data/lib/mangopay/model/entity/entity_base.rb +18 -0
- data/lib/mangopay/model/entity/hook.rb +26 -0
- data/lib/mangopay/model/entity/kyc_document.rb +28 -0
- data/lib/mangopay/model/entity/mandate.rb +51 -0
- data/lib/mangopay/model/entity/pay_in/bank_wire_direct_pay_in.rb +22 -0
- data/lib/mangopay/model/entity/pay_in/card_direct_pay_in.rb +33 -0
- data/lib/mangopay/model/entity/pay_in/card_pre_authorized_pay_in.rb +13 -0
- data/lib/mangopay/model/entity/pay_in/card_web_pay_in.rb +40 -0
- data/lib/mangopay/model/entity/pay_in/direct_debit_direct_pay_in.rb +23 -0
- data/lib/mangopay/model/entity/pay_in/direct_debit_web_pay_in.rb +38 -0
- data/lib/mangopay/model/entity/pay_in/pay_in.rb +16 -0
- data/lib/mangopay/model/entity/pay_out.rb +22 -0
- data/lib/mangopay/model/entity/pre_authorization.rb +68 -0
- data/lib/mangopay/model/entity/refund.rb +18 -0
- data/lib/mangopay/model/entity/report.rb +51 -0
- data/lib/mangopay/model/entity/repudiation.rb +18 -0
- data/lib/mangopay/model/entity/settlement_transfer.rb +17 -0
- data/lib/mangopay/model/entity/transaction.rb +52 -0
- data/lib/mangopay/model/entity/transfer.rb +13 -0
- data/lib/mangopay/model/entity/ubo_declaration.rb +32 -0
- data/lib/mangopay/model/entity/user/legal_user.rb +53 -0
- data/lib/mangopay/model/entity/user/natural_user.rb +50 -0
- data/lib/mangopay/model/entity/user/user.rb +18 -0
- data/lib/mangopay/model/entity/wallet.rb +28 -0
- data/lib/mangopay/model/enum/account_type.rb +24 -0
- data/lib/mangopay/model/enum/card_status.rb +15 -0
- data/lib/mangopay/model/enum/card_type.rb +33 -0
- data/lib/mangopay/model/enum/card_validity.rb +19 -0
- data/lib/mangopay/model/enum/country_iso.rb +759 -0
- data/lib/mangopay/model/enum/culture_code.rb +44 -0
- data/lib/mangopay/model/enum/currency_iso.rb +552 -0
- data/lib/mangopay/model/enum/declared_ubo_refused_reason_type.rb +16 -0
- data/lib/mangopay/model/enum/declared_ubo_status.rb +18 -0
- data/lib/mangopay/model/enum/deposit_type.rb +15 -0
- data/lib/mangopay/model/enum/direct_debit_type.rb +13 -0
- data/lib/mangopay/model/enum/dispute_doc_refused_reason_type.rb +25 -0
- data/lib/mangopay/model/enum/dispute_document_type.rb +23 -0
- data/lib/mangopay/model/enum/dispute_reason_type.rb +33 -0
- data/lib/mangopay/model/enum/dispute_status.rb +21 -0
- data/lib/mangopay/model/enum/dispute_type.rb +15 -0
- data/lib/mangopay/model/enum/document_status.rb +21 -0
- data/lib/mangopay/model/enum/download_format.rb +11 -0
- data/lib/mangopay/model/enum/event_type.rb +74 -0
- data/lib/mangopay/model/enum/funds_type.rb +15 -0
- data/lib/mangopay/model/enum/hook_status.rb +13 -0
- data/lib/mangopay/model/enum/hook_validity.rb +15 -0
- data/lib/mangopay/model/enum/income_range.rb +21 -0
- data/lib/mangopay/model/enum/kyc_doc_refused_reason_type.rb +37 -0
- data/lib/mangopay/model/enum/kyc_document_type.rb +19 -0
- data/lib/mangopay/model/enum/kyc_level.rb +13 -0
- data/lib/mangopay/model/enum/legal_person_type.rb +15 -0
- data/lib/mangopay/model/enum/mandate_culture_code.rb +23 -0
- data/lib/mangopay/model/enum/mandate_execution_type.rb +11 -0
- data/lib/mangopay/model/enum/mandate_scheme.rb +13 -0
- data/lib/mangopay/model/enum/mandate_status.rb +24 -0
- data/lib/mangopay/model/enum/mandate_type.rb +11 -0
- data/lib/mangopay/model/enum/natural_user_capacity.rb +15 -0
- data/lib/mangopay/model/enum/pay_in_execution_type.rb +18 -0
- data/lib/mangopay/model/enum/pay_in_payment_type.rb +21 -0
- data/lib/mangopay/model/enum/pay_out_payment_type.rb +11 -0
- data/lib/mangopay/model/enum/payment_status.rb +21 -0
- data/lib/mangopay/model/enum/person_type.rb +15 -0
- data/lib/mangopay/model/enum/platform_type.rb +23 -0
- data/lib/mangopay/model/enum/pre_authorization_execution_type.rb +11 -0
- data/lib/mangopay/model/enum/pre_authorization_status.rb +18 -0
- data/lib/mangopay/model/enum/refund_reason_type.rb +21 -0
- data/lib/mangopay/model/enum/report_status.rb +17 -0
- data/lib/mangopay/model/enum/report_type.rb +13 -0
- data/lib/mangopay/model/enum/secure_mode.rb +16 -0
- data/lib/mangopay/model/enum/transaction_nature.rb +17 -0
- data/lib/mangopay/model/enum/transaction_status.rb +15 -0
- data/lib/mangopay/model/enum/transaction_type.rb +15 -0
- data/lib/mangopay/model/enum/ubo_declaration_refused_reason_type.rb +19 -0
- data/lib/mangopay/model/enum/ubo_declaration_status.rb +21 -0
- data/lib/mangopay/model/event.rb +18 -0
- data/lib/mangopay/model/model.rb +194 -0
- data/lib/mangopay/model/money.rb +17 -0
- data/lib/mangopay/model/pay_in_web_extended_view.rb +31 -0
- data/lib/mangopay/model/refund_reason.rb +15 -0
- data/lib/mangopay/model/report_filter.rb +83 -0
- data/lib/mangopay/model/request/cancel_request.rb +16 -0
- data/lib/mangopay/model/request/complete_registration_request.rb +13 -0
- data/lib/mangopay/model/request/currency_request.rb +13 -0
- data/lib/mangopay/model/request/deactivation_request.rb +10 -0
- data/lib/mangopay/model/request/filter_request.rb +38 -0
- data/lib/mangopay/model/request/submit_document_request.rb +14 -0
- data/lib/mangopay/model/request/submit_ubo_declaration_request.rb +14 -0
- data/lib/mangopay/model/request/upload_file_request.rb +9 -0
- data/lib/mangopay/model/response_replica.rb +27 -0
- data/lib/mangopay/util/custom_formatter.rb +12 -0
- data/lib/mangopay/util/custom_logger.rb +34 -0
- data/lib/mangopay/util/enum.rb +52 -0
- data/lib/mangopay/util/file_encoder.rb +16 -0
- data/lib/mangopay/util/non_instantiable.rb +6 -0
- data/lib/mangopay/util/storage_strategy.rb +10 -0
- data/lib/mangopay/util/void_logger.rb +6 -0
- data/mangopay.gemspec +32 -0
- data/spec/context/address_context.rb +25 -0
- data/spec/context/bank_account_context.rb +138 -0
- data/spec/context/card_context.rb +46 -0
- data/spec/context/client_context.rb +45 -0
- data/spec/context/dispute_context.rb +37 -0
- data/spec/context/dispute_document_context.rb +20 -0
- data/spec/context/hook_context.rb +16 -0
- data/spec/context/kyc_document_context.rb +23 -0
- data/spec/context/mandate_context.rb +27 -0
- data/spec/context/pay_in_context.rb +225 -0
- data/spec/context/pay_out_context.rb +39 -0
- data/spec/context/pre_authorization_context.rb +41 -0
- data/spec/context/refund_context.rb +33 -0
- data/spec/context/report_context.rb +22 -0
- data/spec/context/repudiation_context.rb +19 -0
- data/spec/context/settlement_transfer_context.rb +28 -0
- data/spec/context/transfer_context.rb +51 -0
- data/spec/context/ubo_declaration_context.rb +25 -0
- data/spec/context/user_context.rb +83 -0
- data/spec/context/wallet_context.rb +53 -0
- data/spec/mangopay/bank_accounts_spec.rb +229 -0
- data/spec/mangopay/cards_spec.rb +135 -0
- data/spec/mangopay/client_wallets_spec.rb +148 -0
- data/spec/mangopay/clients_spec.rb +55 -0
- data/spec/mangopay/configuration_spec.rb +126 -0
- data/spec/mangopay/dispute_documents_spec.rb +174 -0
- data/spec/mangopay/disputes_spec.rb +265 -0
- data/spec/mangopay/e_money_spec.rb +38 -0
- data/spec/mangopay/events_spec.rb +50 -0
- data/spec/mangopay/hooks_spec.rb +71 -0
- data/spec/mangopay/kyc_documents_spec.rb +180 -0
- data/spec/mangopay/mandates_spec.rb +219 -0
- data/spec/mangopay/oauth_tokens_spec.rb +41 -0
- data/spec/mangopay/pay_ins_spec.rb +181 -0
- data/spec/mangopay/pay_outs_spec.rb +39 -0
- data/spec/mangopay/pre_authorizations_spec.rb +58 -0
- data/spec/mangopay/refunds_spec.rb +40 -0
- data/spec/mangopay/reports_spec.rb +121 -0
- data/spec/mangopay/responses_spec.rb +295 -0
- data/spec/mangopay/settlement_transfers_spec.rb +37 -0
- data/spec/mangopay/transactions_spec.rb +233 -0
- data/spec/mangopay/transfers_spec.rb +38 -0
- data/spec/mangopay/ubo_declarations_spec.rb +65 -0
- data/spec/mangopay/users_spec.rb +146 -0
- data/spec/mangopay/wallets_spec.rb +104 -0
- data/spec/resources/logo.png +0 -0
- data/spec/resources/test_pdf.pdf +0 -0
- data/spec/spec_helper.rb +72 -0
- metadata +349 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
require_relative '../uri_provider'
|
2
|
+
require_relative '../../model/request/cancel_request'
|
3
|
+
|
4
|
+
module MangoApi
|
5
|
+
|
6
|
+
# Provides API method delegates concerning the +PreAuthorization+ entity
|
7
|
+
module PreAuthorizations
|
8
|
+
class << self
|
9
|
+
include UriProvider
|
10
|
+
|
11
|
+
# Creates a new Pre-Authorization entity.
|
12
|
+
#
|
13
|
+
# +PreAuthorization+ properties:
|
14
|
+
# * Required
|
15
|
+
# * author_id
|
16
|
+
# * debited_funds
|
17
|
+
# * card_id
|
18
|
+
# * secure_mode_return_url
|
19
|
+
# * Optional
|
20
|
+
# * tag
|
21
|
+
# * secure_mode
|
22
|
+
#
|
23
|
+
# @param +pre_auth+ [PreAuthorization] the pre-authorization
|
24
|
+
# data model object
|
25
|
+
# @param +id_key+ [String] idempotency key for future response replication
|
26
|
+
# @return [PreAuthorization] the newly-created PreAuthorization
|
27
|
+
# entity object
|
28
|
+
def create(pre_auth, id_key = nil)
|
29
|
+
uri = provide_uri(:create_pre_authorization)
|
30
|
+
response = HttpClient.post(uri, pre_auth, id_key)
|
31
|
+
parse response
|
32
|
+
end
|
33
|
+
|
34
|
+
# Retrieves a Pre-Authorization entity.
|
35
|
+
#
|
36
|
+
# @param +id+ [String] ID of the pre-authorization to retrieve
|
37
|
+
# @return [PreAuthorization] the requested Pre-Authorization
|
38
|
+
# entity object
|
39
|
+
def get(id)
|
40
|
+
uri = provide_uri(:get_pre_authorization, id)
|
41
|
+
response = HttpClient.get(uri)
|
42
|
+
parse response
|
43
|
+
end
|
44
|
+
|
45
|
+
# Cancels a Pre-Authorization entity.
|
46
|
+
#
|
47
|
+
# @param +id+ [String] ID of the pre-authorization to cancel
|
48
|
+
# @return [PreAuthorization] the requested Pre-Authorization
|
49
|
+
# entity object
|
50
|
+
def cancel(id)
|
51
|
+
uri = provide_uri(:cancel_pre_authorization, id)
|
52
|
+
cancel_request = CancelRequest.new
|
53
|
+
response = HttpClient.put(uri, cancel_request)
|
54
|
+
parse response
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
# Parses a JSON-originating hash into the corresponding
|
60
|
+
# PreAuthorization entity object.
|
61
|
+
#
|
62
|
+
# @param +response+ [Hash] JSON-originating data hash
|
63
|
+
# @return [PreAuthorization] corresponding PreAuthorization entity object
|
64
|
+
def parse(response)
|
65
|
+
MangoModel::PreAuthorization.new.dejsonify response
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative '../uri_provider'
|
2
|
+
|
3
|
+
module MangoApi
|
4
|
+
|
5
|
+
# Provides API method delegates concerning the +Refund+ entity
|
6
|
+
module Refunds
|
7
|
+
class << self
|
8
|
+
include UriProvider
|
9
|
+
|
10
|
+
# Creates a Pay-In Refund, which is a request to reimburse a user
|
11
|
+
# on their payment card. The money which was paid will automatically
|
12
|
+
# go back to the user's bank account.
|
13
|
+
#
|
14
|
+
# +Refund+ properties:
|
15
|
+
# * Required
|
16
|
+
# * author_id
|
17
|
+
# * Optional
|
18
|
+
# * tag
|
19
|
+
# * debited_funds
|
20
|
+
# * fees
|
21
|
+
#
|
22
|
+
# @param +id+ [String] ID of the pay-in being refunded
|
23
|
+
# @param +refund+ [Refund] model object of the refund being created
|
24
|
+
# @param +id_key+ [String] idempotency key for future response replication
|
25
|
+
# @return [Refund] the newly-created Refund entity object
|
26
|
+
def create_for_pay_in(id, refund, id_key = nil)
|
27
|
+
uri = provide_uri(:create_pay_in_refund, id)
|
28
|
+
response = HttpClient.post(uri, refund, id_key)
|
29
|
+
parse response
|
30
|
+
end
|
31
|
+
|
32
|
+
# Creates a Transfer Refund.
|
33
|
+
#
|
34
|
+
# +Refund+ properties:
|
35
|
+
# * Required
|
36
|
+
# * author_id
|
37
|
+
# * Optional
|
38
|
+
# * tag
|
39
|
+
#
|
40
|
+
# @param +id+ [String] ID of the transfer being refunded
|
41
|
+
# @param +refund+ [Refund] model object of the refund being created
|
42
|
+
# @param +id_key+ [String] idempotency key for future response replication
|
43
|
+
# @return [Refund] the newly-created Refund entity object
|
44
|
+
def create_for_transfer(id, refund, id_key = nil)
|
45
|
+
uri = provide_uri(:create_transfer_refund, id)
|
46
|
+
response = HttpClient.post(uri, refund, id_key)
|
47
|
+
parse response
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
# Parses a JSON-originating hash into the corresponding
|
53
|
+
# Refund entity object.
|
54
|
+
#
|
55
|
+
# @param +response+ [Hash] JSON-originating data hash
|
56
|
+
# @return [Refund] corresponding Refund entity object
|
57
|
+
def parse(response)
|
58
|
+
MangoModel::Refund.new.dejsonify response
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require_relative '../uri_provider'
|
2
|
+
require_relative '../../model/report_filter'
|
3
|
+
|
4
|
+
module MangoApi
|
5
|
+
|
6
|
+
# Provides API method delegates concerning the +Report+ entity
|
7
|
+
module Reports
|
8
|
+
class << self
|
9
|
+
include UriProvider
|
10
|
+
|
11
|
+
# Requests creation of a transaction report.
|
12
|
+
# Yields a +ReportFilter+ object for caller to specify
|
13
|
+
# filtering parameters in a provided block.
|
14
|
+
#
|
15
|
+
# +Report+ properties:
|
16
|
+
# * Optional
|
17
|
+
# * tag
|
18
|
+
# * callback_url
|
19
|
+
# * download_format
|
20
|
+
# * sort
|
21
|
+
# * preview
|
22
|
+
# * columns
|
23
|
+
#
|
24
|
+
# Available +columns+ values: Alias, AuthorId,
|
25
|
+
# BankAccountId, BankWireRef, CardId, CardType, Country,
|
26
|
+
# CreationDate, CreditedFundsAmount, CreditedFundsCurrency,
|
27
|
+
# CreditedUserId, CreditedWalletId, Culture, DebitedFundsAmount,
|
28
|
+
# DebitedFundsCurrency, DebitedWalletId, DeclaredDebitedFundsAmount,
|
29
|
+
# DeclaredDebitedFundsCurrency, DeclaredFeesAmount, DeclaredFeesCurrency,
|
30
|
+
# ExecutionDate, ExecutionType, ExpirationDate, FeesAmount, FeesCurrency,
|
31
|
+
# Id, Nature, PaymentType, PreauthorizationId, ResultCode, ResultMessage,
|
32
|
+
# Status, Tag, Type, WireReference
|
33
|
+
#
|
34
|
+
# Allowed +ReportFilter+ params:
|
35
|
+
# * after_date
|
36
|
+
# * before_date
|
37
|
+
# * type
|
38
|
+
# * status
|
39
|
+
# * nature
|
40
|
+
# * min_debited_funds_amount
|
41
|
+
# * min_debited_funds_currency
|
42
|
+
# * max_debited_funds_amount
|
43
|
+
# * max_debited_funds_currency
|
44
|
+
# * min_fees_amount
|
45
|
+
# * min_fees_currency
|
46
|
+
# * max_fees_amount
|
47
|
+
# * max_fees_currency
|
48
|
+
# * author_id
|
49
|
+
# * wallet_id
|
50
|
+
#
|
51
|
+
# @param +report+ [Report] model object of the report to be created
|
52
|
+
# @return [Report] the newly-created Report entity object
|
53
|
+
def create_for_transactions(report)
|
54
|
+
uri = provide_uri(:create_transaction_report)
|
55
|
+
report.filters = ReportFilter.new unless report.filters
|
56
|
+
yield report.filters if block_given?
|
57
|
+
response = HttpClient.post(uri, report)
|
58
|
+
parse response
|
59
|
+
end
|
60
|
+
|
61
|
+
# Requests creation of a wallet report.
|
62
|
+
# Yields a +ReportFilter+ object for caller to specify
|
63
|
+
# filtering parameters in a provided block.
|
64
|
+
#
|
65
|
+
# +Report+ properties:
|
66
|
+
# * Optional
|
67
|
+
# * tag
|
68
|
+
# * callback_url
|
69
|
+
# * download_format
|
70
|
+
# * sort
|
71
|
+
# * preview
|
72
|
+
# * columns
|
73
|
+
#
|
74
|
+
# Available +columns+ values: Id, Tag, CreationDate, Owners, Description,
|
75
|
+
# BalanceAmount, BalanceCurrency, Currency, FundsType
|
76
|
+
#
|
77
|
+
# Allowed +FilterRequest+ params:
|
78
|
+
# * after_date
|
79
|
+
# * before_date
|
80
|
+
# * owner_id
|
81
|
+
# * currency
|
82
|
+
# * min_balance_amount
|
83
|
+
# * min_balance_currency
|
84
|
+
# * max_balance_amount
|
85
|
+
# * max_balance_currency
|
86
|
+
#
|
87
|
+
# @param +report+ [Report] model object of the report to be created
|
88
|
+
# @return [Report] the newly-created Report entity object
|
89
|
+
def create_for_wallets(report)
|
90
|
+
uri = provide_uri(:create_wallet_report)
|
91
|
+
report.filters = ReportFilter.new unless report.filters
|
92
|
+
yield report.filters if block_given?
|
93
|
+
response = HttpClient.post(uri, report)
|
94
|
+
parse response
|
95
|
+
end
|
96
|
+
|
97
|
+
# Retrieves a report entity.
|
98
|
+
#
|
99
|
+
# @param +id+ [String] ID of the report to retrieve
|
100
|
+
# @return [Report] the requested Report entity object
|
101
|
+
def get(id)
|
102
|
+
uri = provide_uri(:get_report, id)
|
103
|
+
response = HttpClient.get(uri)
|
104
|
+
parse response
|
105
|
+
end
|
106
|
+
|
107
|
+
# Retrieves report entities. Allows configuration of paging and
|
108
|
+
# sorting parameters by yielding a filtering object to a provided
|
109
|
+
# block. When no filters are specified, will retrieve the first
|
110
|
+
# page of 10 newest results.
|
111
|
+
#
|
112
|
+
# Allowed +FilterRequest+ params:
|
113
|
+
# * page
|
114
|
+
# * per_page
|
115
|
+
# * sort_field and sort_direction
|
116
|
+
# * before_date
|
117
|
+
# * after_date
|
118
|
+
#
|
119
|
+
# @return [Array] corresponding Report entity objects
|
120
|
+
def all
|
121
|
+
uri = provide_uri(:get_reports)
|
122
|
+
filter_request = nil
|
123
|
+
yield filter_request = FilterRequest.new if block_given?
|
124
|
+
results = HttpClient.get(uri, filter_request)
|
125
|
+
parse_results results
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
# Parses an array of JSON-originating hashes into the corresponding
|
131
|
+
# Report entity objects.
|
132
|
+
#
|
133
|
+
# @param +results+ [Array] JSON-originating data hashes
|
134
|
+
# @return [Array] parsed Report entity objects
|
135
|
+
def parse_results(results)
|
136
|
+
results.collect do |entity|
|
137
|
+
parse entity
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# Parses a JSON-originating hash into the corresponding
|
142
|
+
# Report entity object.
|
143
|
+
#
|
144
|
+
# @param +response+ [Hash] JSON-originating data hash
|
145
|
+
# @return [Report] corresponding Report entity object
|
146
|
+
def parse(response)
|
147
|
+
MangoModel::Report.new.dejsonify response
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative '../uri_provider'
|
2
|
+
|
3
|
+
module MangoApi
|
4
|
+
|
5
|
+
# Provides API method delegates concerning the +Repudiation+ entity
|
6
|
+
module Repudiations
|
7
|
+
class << self
|
8
|
+
include UriProvider
|
9
|
+
|
10
|
+
# Retrieves a repudiation entity.
|
11
|
+
#
|
12
|
+
# @param +id+ [String] ID of the repudiation to retrieve
|
13
|
+
# @return [Repudiation] the requested Repudiation entity object
|
14
|
+
def get(id)
|
15
|
+
uri = provide_uri(:get_repudiation, id)
|
16
|
+
response = HttpClient.get(uri)
|
17
|
+
parse response
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Parses a JSON-originating hash into the corresponding
|
23
|
+
# Repudiation entity object.
|
24
|
+
#
|
25
|
+
# @param +response+ [Hash] JSON-originating data hash
|
26
|
+
# @return [Repudiation] corresponding Repudiation entity object
|
27
|
+
def parse(response)
|
28
|
+
MangoModel::Repudiation.new.dejsonify response
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require_relative '../uri_provider'
|
2
|
+
require_relative '../../model/response_replica'
|
3
|
+
|
4
|
+
module MangoApi
|
5
|
+
|
6
|
+
# Provides API method delegates for replicating
|
7
|
+
# responses based on idempotency keys.
|
8
|
+
module Responses
|
9
|
+
class << self
|
10
|
+
include UriProvider
|
11
|
+
|
12
|
+
# Retrieves the response of a previous request by
|
13
|
+
# the idempotency key which was provided at the time.
|
14
|
+
#
|
15
|
+
# @param +id_key+ Idempotency key provided with the original request
|
16
|
+
# @return [ResponseReplica] Replica of the original response
|
17
|
+
def replicate(id_key)
|
18
|
+
uri = provide_uri(:replicate_response, id_key)
|
19
|
+
response = HttpClient.get uri
|
20
|
+
parse response
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# Parses the received response into a corresponding object
|
26
|
+
#
|
27
|
+
# @param +response+ [Hash] hashed response
|
28
|
+
# @return [ResponseReplica] De-serialized typed response replication
|
29
|
+
def parse(response)
|
30
|
+
replica = MangoModel::ResponseReplica.new.dejsonify response
|
31
|
+
type = entity_type(replica.resource, replica.request_url)
|
32
|
+
replica.resource = type.new.dejsonify replica.resource if type
|
33
|
+
replica
|
34
|
+
end
|
35
|
+
|
36
|
+
# Asserts the effective type of entity returned
|
37
|
+
# in an API response, based on the request URL.
|
38
|
+
#
|
39
|
+
# @param +hash+ [Hash] hashed JSON response
|
40
|
+
# @param +source_url+ [String] URL from where the entity was returned
|
41
|
+
# @return [Class] actual type of the entity
|
42
|
+
def entity_type(hash, source_url)
|
43
|
+
case source_url
|
44
|
+
when %r{/reports}
|
45
|
+
MangoModel::Report
|
46
|
+
when %r{(/settlementtransfer|/settlements)}
|
47
|
+
MangoModel::SettlementTransfer
|
48
|
+
when %r{/repudiations}
|
49
|
+
MangoModel::Repudiation
|
50
|
+
when %r{(/disputes.+/documents|dispute-documents)}
|
51
|
+
MangoModel::DisputeDocument
|
52
|
+
when %r{/disputes}
|
53
|
+
MangoModel::Dispute
|
54
|
+
when %r{(/kyc/documents.+/consult|/dispute-documents.+/consult)}
|
55
|
+
MangoModel::DocumentPageConsult
|
56
|
+
when %r{/refunds}
|
57
|
+
MangoModel::Refund
|
58
|
+
when %r{/events}
|
59
|
+
MangoModel::Event
|
60
|
+
when %r{/hooks}
|
61
|
+
MangoModel::Hook
|
62
|
+
when %r{/ubodeclarations}
|
63
|
+
MangoModel::UboDeclaration
|
64
|
+
when %r{/kyc/documents}
|
65
|
+
MangoModel::KycDocument
|
66
|
+
when %r{/payouts/}
|
67
|
+
MangoModel::PayOut
|
68
|
+
when %r{/extended/}
|
69
|
+
MangoModel::PayInWebExtendedView
|
70
|
+
when %r{/mandates}
|
71
|
+
MangoModel:: Mandate
|
72
|
+
when %r{/transactions}
|
73
|
+
MangoModel::Transaction
|
74
|
+
when %r{/preauthorizations}
|
75
|
+
MangoModel::PreAuthorization
|
76
|
+
when %r{/cards}
|
77
|
+
MangoModel::Card
|
78
|
+
when %r{/cardregistrations}
|
79
|
+
MangoModel::CardRegistration
|
80
|
+
when %r{/payins}
|
81
|
+
MangoModel.pay_in_type(hash)
|
82
|
+
when %r{/transfers}
|
83
|
+
MangoModel::Transfer
|
84
|
+
when %r{/emoney}
|
85
|
+
MangoModel::EMoney
|
86
|
+
when %r{/bankaccounts}
|
87
|
+
MangoModel.bank_account_type(hash)
|
88
|
+
when %r{/clients/wallets}
|
89
|
+
MangoModel::ClientWallet
|
90
|
+
when %r{/wallets}
|
91
|
+
MangoModel::Wallet
|
92
|
+
when %r{/users}
|
93
|
+
MangoModel.user_type(hash)
|
94
|
+
when %r{/clients}
|
95
|
+
MangoModel::Client
|
96
|
+
else
|
97
|
+
raise 'Could not assert effective type for entity source: ' + source_url
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative '../uri_provider'
|
2
|
+
|
3
|
+
module MangoApi
|
4
|
+
|
5
|
+
# Provides API method delegates concerning the +SettlementTransfer+ entity
|
6
|
+
module SettlementTransfers
|
7
|
+
class << self
|
8
|
+
include UriProvider
|
9
|
+
|
10
|
+
# Creates a new settlement transfer entity.
|
11
|
+
#
|
12
|
+
# +SettlementTransfer+ properties:
|
13
|
+
# * Required
|
14
|
+
# * author_id
|
15
|
+
# * debited_funds
|
16
|
+
# * fees
|
17
|
+
# * Optional
|
18
|
+
# * tag
|
19
|
+
#
|
20
|
+
# @param +repudiation_id+ [String] ID of the corresponding repudiation
|
21
|
+
# @param +transfer+ [SettlementTransfer] model object of the settlement
|
22
|
+
# transfer to be created
|
23
|
+
# @return [SettlementTransfer] the newly-created SettlementTransfer
|
24
|
+
# entity object
|
25
|
+
def create(repudiation_id, transfer)
|
26
|
+
uri = provide_uri(:create_settlement_transfer, repudiation_id)
|
27
|
+
response = HttpClient.post(uri, transfer)
|
28
|
+
parse response
|
29
|
+
end
|
30
|
+
|
31
|
+
# Retrieves a settlement transfer entity.
|
32
|
+
#
|
33
|
+
# @param +id+ [String] ID of the settlement transfer to retrieve
|
34
|
+
# @return [SettlementTransfer] the requested SettlementTransfer
|
35
|
+
# entity object
|
36
|
+
def get(id)
|
37
|
+
uri = provide_uri(:get_settlement_transfer, id)
|
38
|
+
response = HttpClient.get(uri)
|
39
|
+
parse response
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# Parses a JSON-originating hash into the corresponding
|
45
|
+
# SettlementTransfer entity object.
|
46
|
+
#
|
47
|
+
# @param +response+ [Hash] JSON-originating data hash
|
48
|
+
# @return [SettlementTransfer] corresponding SettlementTransfer
|
49
|
+
# entity object
|
50
|
+
def parse(response)
|
51
|
+
MangoModel::SettlementTransfer.new.dejsonify response
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|