Module: MangoApi::DisputeDocuments

Extended by:
UriProvider
Defined in:
lib/mangopay/api/service/dispute_documents.rb

Overview

Provides API method delegates for the DisputeDocument entity

Class Method Summary collapse

Methods included from UriProvider

provide_uri

Class Method Details

.all {|filter_request = FilterRequest.new| ... } ⇒ Array

Retrieves dispute documents belonging to the current environment’s client. Allows configuration of paging and sorting parameters by yielding a filtering object to a provided block. When no filters are specified, will retrieve the first page of 10 newest results.

Allowed FilterRequest params:

  • page

  • per_page

  • sort_field and sort_direction

  • before_date

  • after_date

  • status

  • type

Yields:

Returns:

  • (Array)

    corresponding DisputeDocument entity objects



106
107
108
109
110
111
112
# File 'lib/mangopay/api/service/dispute_documents.rb', line 106

def all
  uri = provide_uri(:get_dispute_documents)
  filter_request = nil
  yield filter_request = FilterRequest.new if block_given?
  results = HttpClient.get(uri, filter_request)
  parse_results results
end

.consult(id) ⇒ Array

Creates temporary URLs where each page of a dispute document can be viewed

Parameters:

  • +id+ (String)

    ID of the document whose pages to consult

Returns:

  • (Array)

    the corresponding DocumentPageConsult objects



119
120
121
122
123
# File 'lib/mangopay/api/service/dispute_documents.rb', line 119

def consult(id)
  uri = provide_uri(:consult_dispute_document, id)
  results = HttpClient.post(uri, nil)
  parse_consults results
end

.create(document, dispute_id) ⇒ DisputeDocument

Creates a new dispute document entity.

DisputeDocument properties:

  • Required

    • type

  • Optional

    • tag

document to be created

Parameters:

  • +document+ (DisputeDocument)

    model object of the dispute

  • +dispute_id+ (String)

    ID of the corresponding dispute

Returns:

  • (DisputeDocument)

    the newly-created DisputeDocument entity object



25
26
27
28
29
# File 'lib/mangopay/api/service/dispute_documents.rb', line 25

def create(document, dispute_id)
  uri = provide_uri(:create_dispute_document, dispute_id)
  response = HttpClient.post(uri, document)
  parse response
end

.get(id) ⇒ DisputeDocument

Retrieves a dispute document entity.

Parameters:

  • +id+ (String)

    ID of the dispute document to retrieve

Returns:

  • (DisputeDocument)

    the requested DisputeDocument entity object



61
62
63
64
65
# File 'lib/mangopay/api/service/dispute_documents.rb', line 61

def get(id)
  uri = provide_uri(:get_dispute_document, id)
  response = HttpClient.get(uri)
  parse response
end

.of_dispute(id) {|filter_request = FilterRequest.new| ... } ⇒ Array

Retrieves dispute documents belonging to a certain dispute. Allows configuration of paging and sorting parameters by yielding a filtering object to a provided block. When no filters are specified, will retrieve the first page of 10 newest results.

Allowed FilterRequest params:

  • page

  • per_page

  • sort_field and sort_direction

  • before_date

  • after_date

  • status

  • type

Parameters:

  • +id+ (String)

    ID of the dispute whose documents to retrieve

Yields:

Returns:

  • (Array)

    corresponding DisputeDocument entity objects



83
84
85
86
87
88
89
# File 'lib/mangopay/api/service/dispute_documents.rb', line 83

def of_dispute(id)
  uri = provide_uri(:get_disputes_documents, id)
  filter_request = nil
  yield filter_request = FilterRequest.new if block_given?
  results = HttpClient.get(uri, filter_request)
  parse_results results
end

.submit(id, dispute_id) ⇒ DisputeDocument

Submits a dispute document entity for approval

Parameters:

  • +id+ (String)

    ID of the dispute document to submit

  • +dispute_id+ (String)

    ID of the corresponding dispute

Returns:

  • (DisputeDocument)

    the submitted DisputeDocument entity object



50
51
52
53
54
55
# File 'lib/mangopay/api/service/dispute_documents.rb', line 50

def submit(id, dispute_id)
  uri = provide_uri(:submit_dispute_document, dispute_id, id)
  request = SubmitDocumentRequest.new
  response = HttpClient.put(uri, request)
  parse response
end

.upload_page(id, dispute_id, path) ⇒ Object

Uploads a dispute document page. Allowed extensions: .pdf .jpeg .jpg .gif .png

that the page is being uploaded for

Parameters:

  • +id+ (String)

    ID of the dispute document entity

  • +dispute_id+ (String)

    ID of the corresponding dispute entity

  • +path+ (String)

    path to the file to upload



38
39
40
41
42
43
# File 'lib/mangopay/api/service/dispute_documents.rb', line 38

def upload_page(id, dispute_id, path)
  uri = provide_uri(:upload_dispute_document_page, dispute_id, id)
  body = UploadFileRequest.new
  body.file = FileEncoder.encode_base64 path
  HttpClient.post(uri, body)
end