Class: MangoPay::Dispute
- Includes:
- HTTPCalls::Fetch, HTTPCalls::Update
- Defined in:
- lib/mangopay/dispute.rb
Overview
Class Method Summary collapse
- .close(dispute_id, idempotency_key = nil) ⇒ Object
- .consult_url(document_id) ⇒ Object
-
.contest(dispute_id, contested_funds) ⇒ Object
contested_funds
: Money hash see ‘Contest’ section @ docs.mangopay.com/api-references/disputes/disputes/. -
.create_document(dispute_id, params, idempotency_key = nil) ⇒ Object
params
: hash; see docs.mangopay.com/api-references/disputes/dispute-documents/. -
.create_document_consult(document_id) ⇒ Object
Creates temporary URLs where each page of a dispute document can be viewed.
-
.create_document_page(dispute_id, document_id, file_content_base64, file_path = nil, idempotency_key = nil) ⇒ Object
Adds the file page (attachment) to the given document.
-
.create_settlement_transfer(repudiation_id, params, idempotency_key = nil) ⇒ Object
params
: hash; see docs.mangopay.com/api-references/disputes/settlement-transfers/. - .fetch_document(document_id) ⇒ Object
-
.fetch_documents(dispute_id = nil, filters = {}) ⇒ Object
Fetches list of dispute documents: - for the particular dispute if
dispute_id
is provided (not nil) - or for all disputes otherwise. - .fetch_for_user(user_id, filters = {}) ⇒ Object
- .fetch_for_wallet(wallet_id, filters = {}) ⇒ Object
- .fetch_pending_settlement(filters = {}) ⇒ Object
- .fetch_repudiation(repudiation_id, idempotency_key = nil) ⇒ Object
- .fetch_settlement_transfer(transfer_id) ⇒ Object
- .resubmit(dispute_id) ⇒ Object
- .transactions(dispute_id, filters = {}) ⇒ Object
-
.update_document(dispute_id, document_id, params) ⇒ Object
params
: hash; see ‘Edit’ section @ docs.mangopay.com/api-references/disputes/dispute-documents/.
Methods included from HTTPCalls::Update
Methods included from HTTPCalls::Fetch
Methods inherited from Resource
Class Method Details
.close(dispute_id, idempotency_key = nil) ⇒ Object
11 12 13 14 |
# File 'lib/mangopay/dispute.rb', line 11 def close(dispute_id, idempotency_key = nil) url = url(dispute_id) + "/close/" MangoPay.request(:put, url, {}, {}, idempotency_key) end |
.consult_url(document_id) ⇒ Object
142 143 144 |
# File 'lib/mangopay/dispute.rb', line 142 def consult_url(document_id) "#{MangoPay.api_path}/dispute-documents/#{document_id}/consult" end |
.contest(dispute_id, contested_funds) ⇒ Object
contested_funds
: Money hash see ‘Contest’ section @ docs.mangopay.com/api-references/disputes/disputes/
18 19 20 21 |
# File 'lib/mangopay/dispute.rb', line 18 def contest(dispute_id, contested_funds) url = url(dispute_id) + "/submit/" MangoPay.request(:put, url, {ContestedFunds: contested_funds}) end |
.create_document(dispute_id, params, idempotency_key = nil) ⇒ Object
params
: hash; see docs.mangopay.com/api-references/disputes/dispute-documents/
75 76 77 78 |
# File 'lib/mangopay/dispute.rb', line 75 def create_document(dispute_id, params, idempotency_key = nil) url = url(dispute_id) + "/documents/" MangoPay.request(:post, url, params, {}, idempotency_key) end |
.create_document_consult(document_id) ⇒ Object
Creates temporary URLs where each page of a dispute document can be viewed.
138 139 140 |
# File 'lib/mangopay/dispute.rb', line 138 def create_document_consult(document_id) MangoPay.request(:get, consult_url(document_id), {}, {}) end |
.create_document_page(dispute_id, document_id, file_content_base64, file_path = nil, idempotency_key = nil) ⇒ Object
Adds the file page (attachment) to the given document.
See docs.mangopay.com/api-references/disputes/dispute-document-pages/ :
-
Document have to be in ‘CREATED’ Status
-
You can create as many pages as needed
-
Change Status to ‘VALIDATION_ASKED’ to submit dispute documents
The file_content_base64 param may be:
-
Base64 encoded file content
-
or nil: in this case pass the file path in the next param
119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/mangopay/dispute.rb', line 119 def create_document_page(dispute_id, document_id, file_content_base64, file_path = nil, idempotency_key = nil) if file_content_base64.nil? && !file_path.nil? bts = File.open(file_path, 'rb') { |f| f.read } file_content_base64 = Base64.encode64(bts) end # normally it returns 204 HTTP code on success begin url = url(dispute_id) + "/documents/#{document_id}/pages" MangoPay.request(:post, url, {'File' => file_content_base64}, {}, idempotency_key) rescue ResponseError => ex raise ex unless ex.code == '204' end end |
.create_settlement_transfer(repudiation_id, params, idempotency_key = nil) ⇒ Object
params
: hash; see docs.mangopay.com/api-references/disputes/settlement-transfers/
59 60 61 62 |
# File 'lib/mangopay/dispute.rb', line 59 def create_settlement_transfer(repudiation_id, params, idempotency_key = nil) url = "#{MangoPay.api_path}/repudiations/#{repudiation_id}/settlementtransfer/" MangoPay.request(:post, url, params, {}, idempotency_key) end |
.fetch_document(document_id) ⇒ Object
80 81 82 83 |
# File 'lib/mangopay/dispute.rb', line 80 def fetch_document(document_id) url = "#{MangoPay.api_path}/dispute-documents/#{document_id}" MangoPay.request(:get, url) end |
.fetch_documents(dispute_id = nil, filters = {}) ⇒ Object
Fetches list of dispute documents:
-
for the particular dispute if
dispute_id
is provided (not nil) -
or for all disputes otherwise.
Optional filters
is a hash accepting following keys:
-
page
,per_page
,sort
: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch) -
filters such as
Type
(e.g. ‘REFUND_PROOF’) andStatus
(e.g. ‘VALIDATED’) -
BeforeDate
(timestamp): filters documents with CreationDate before this date -
AfterDate
(timestamp): filters documents with CreationDate after this date
See docs.mangopay.com/api-references/disputes/dispute-documents/
103 104 105 106 |
# File 'lib/mangopay/dispute.rb', line 103 def fetch_documents(dispute_id = nil, filters = {}) url = (dispute_id) ? url(dispute_id) + "/documents/" : "#{MangoPay.api_path}/dispute-documents/" MangoPay.request(:get, url, {}, filters) end |
.fetch_for_user(user_id, filters = {}) ⇒ Object
33 34 35 36 |
# File 'lib/mangopay/dispute.rb', line 33 def fetch_for_user(user_id, filters = {}) url = "#{MangoPay.api_path}/users/#{user_id}/disputes" MangoPay.request(:get, url, {}, filters) end |
.fetch_for_wallet(wallet_id, filters = {}) ⇒ Object
38 39 40 41 |
# File 'lib/mangopay/dispute.rb', line 38 def fetch_for_wallet(wallet_id, filters = {}) url = "#{MangoPay.api_path}/wallets/#{wallet_id}/disputes" MangoPay.request(:get, url, {}, filters) end |
.fetch_pending_settlement(filters = {}) ⇒ Object
43 44 45 46 |
# File 'lib/mangopay/dispute.rb', line 43 def fetch_pending_settlement(filters = {}) url = "#{MangoPay.api_path}/disputes/pendingsettlement" MangoPay.request(:get, url, {}, filters) end |
.fetch_repudiation(repudiation_id, idempotency_key = nil) ⇒ Object
53 54 55 56 |
# File 'lib/mangopay/dispute.rb', line 53 def fetch_repudiation(repudiation_id, idempotency_key = nil) url = "#{MangoPay.api_path}/repudiations/#{repudiation_id}" MangoPay.request(:get, url, {}, {}, idempotency_key) end |
.fetch_settlement_transfer(transfer_id) ⇒ Object
65 66 67 68 |
# File 'lib/mangopay/dispute.rb', line 65 def fetch_settlement_transfer(transfer_id) url = "#{MangoPay.api_path}/settlements/#{transfer_id}" MangoPay.request(:get, url) end |
.resubmit(dispute_id) ⇒ Object
23 24 25 26 |
# File 'lib/mangopay/dispute.rb', line 23 def resubmit(dispute_id) url = url(dispute_id) + "/submit/" MangoPay.request(:put, url) end |
.transactions(dispute_id, filters = {}) ⇒ Object
28 29 30 31 |
# File 'lib/mangopay/dispute.rb', line 28 def transactions(dispute_id, filters = {}) url = url(dispute_id) + "/transactions/" MangoPay.request(:get, url, {}, filters) end |
.update_document(dispute_id, document_id, params) ⇒ Object
params
: hash; see ‘Edit’ section @ docs.mangopay.com/api-references/disputes/dispute-documents/
86 87 88 89 |
# File 'lib/mangopay/dispute.rb', line 86 def update_document(dispute_id, document_id, params) url = url(dispute_id) + "/documents/#{document_id}" MangoPay.request(:put, url, params) end |