Class: TransferZero::DocumentsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/transferzero-sdk/api/documents_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ DocumentsApi

Returns a new instance of DocumentsApi.



19
20
21
# File 'lib/transferzero-sdk/api/documents_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/transferzero-sdk/api/documents_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_document(document_id, opts = {}) ⇒ DocumentResponse

Fetching a document Returns a single document by the Documents ID

Parameters:

  • document_id

    ID of the document to get. Example: `/v1/documents/bf9ff782-e182-45ac-abea-5bce83ad6670`

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



29
30
31
32
# File 'lib/transferzero-sdk/api/documents_api.rb', line 29

def get_document(document_id, opts = {})
  data, _status_code, _headers = get_document_with_http_info(document_id, opts)
  data
end

#get_document_with_http_info(document_id, opts = {}) ⇒ Array<(DocumentResponse, Fixnum, Hash)>

Fetching a document Returns a single document by the Documents ID

Parameters:

  • document_id

    ID of the document to get. Example: &#x60;/v1/documents/bf9ff782-e182-45ac-abea-5bce83ad6670&#x60;

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(DocumentResponse, Fixnum, Hash)>)

    DocumentResponse data, response status code and response headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/transferzero-sdk/api/documents_api.rb', line 39

def get_document_with_http_info(document_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DocumentsApi.get_document ...'
  end
  # verify the required parameter 'document_id' is set
  if @api_client.config.client_side_validation && document_id.nil?
    fail ArgumentError, "Missing the required parameter 'document_id' when calling DocumentsApi.get_document"
  end
  # resource path
  local_var_path = '/documents/{Document ID}'.sub('{' + 'Document ID' + '}', document_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'DocumentResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DocumentsApi#get_document\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_documents(opts = {}) ⇒ DocumentListResponse

Getting a list of documents Fetches a list of documents.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    The page number to request (defaults to 1)

  • :per (Integer)

    The number of results to load per page (defaults to 10)

Returns:



94
95
96
97
# File 'lib/transferzero-sdk/api/documents_api.rb', line 94

def get_documents(opts = {})
  data, _status_code, _headers = get_documents_with_http_info(opts)
  data
end

#get_documents_all(opts = {}) ⇒ Object



77
78
79
80
81
82
83
84
85
86
# File 'lib/transferzero-sdk/api/documents_api.rb', line 77

def get_documents_all(opts = {})
  result = []
  response = get_documents(opts)
  result += response["object"]
  while next_page = response["meta"]["pagination"]["next_page"]
    response = get_documents(opts.merge(page: next_page))
    result += response["object"]
  end
  result
end

#get_documents_with_http_info(opts = {}) ⇒ Array<(DocumentListResponse, Fixnum, Hash)>

Getting a list of documents Fetches a list of documents.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    The page number to request (defaults to 1)

  • :per (Integer)

    The number of results to load per page (defaults to 10)

Returns:

  • (Array<(DocumentListResponse, Fixnum, Hash)>)

    DocumentListResponse data, response status code and response headers



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/transferzero-sdk/api/documents_api.rb', line 105

def get_documents_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DocumentsApi.get_documents ...'
  end
  # resource path
  local_var_path = '/documents'

  # query parameters
  query_params = {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'per'] = opts[:'per'] if !opts[:'per'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'DocumentListResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DocumentsApi#get_documents\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#post_documents(document_request, opts = {}) ⇒ DocumentResponse

Creating a document Creates a new document

Parameters:

  • document_request
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



147
148
149
150
# File 'lib/transferzero-sdk/api/documents_api.rb', line 147

def post_documents(document_request, opts = {})
  data, _status_code, _headers = post_documents_with_http_info(document_request, opts)
  data
end

#post_documents_with_http_info(document_request, opts = {}) ⇒ Array<(DocumentResponse, Fixnum, Hash)>

Creating a document Creates a new document

Parameters:

  • document_request
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(DocumentResponse, Fixnum, Hash)>)

    DocumentResponse data, response status code and response headers



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/transferzero-sdk/api/documents_api.rb', line 157

def post_documents_with_http_info(document_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DocumentsApi.post_documents ...'
  end
  # verify the required parameter 'document_request' is set
  if @api_client.config.client_side_validation && document_request.nil?
    fail ArgumentError, "Missing the required parameter 'document_request' when calling DocumentsApi.post_documents"
  end
  # resource path
  local_var_path = '/documents'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(document_request)
  auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'DocumentResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DocumentsApi#post_documents\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end