xero-ruby icon indicating copy to clipboard operation
xero-ruby copied to clipboard

Incorrect documentation - if_modified_since, where, order

Open swombat opened this issue 1 year ago • 3 comments

API docs say:

xero_client.set_token_set(user.token_set)

xero_tenant_id = 'YOUR_XERO_TENANT_ID'
if_modified_since = "2020-02-06T12:17:43.202-08:00"
where = 'Status==#{XeroRuby::Accounting::Account::ACTIVE}'
order = 'Name ASC'

begin
  response = xero_client.accounting_api.get_accounts(xero_tenant_id, if_modified_since, where, order)
  return response
rescue XeroRuby::ApiError => e
  puts "Exception when calling get_accounts: #{e}"
end

But here is my code:

@api_client.accounting_api.get_accounts(@api_client.last_connection["id"], if_modified_since, where, order)

And the result:

app/apis/xero_api.rb:60:in `get_accounts': wrong number of arguments (given 4, expected 1..2) (ArgumentError)

So it seems the docs are incorrect at least here, probably in other places too. Do the docs need to be re-generated after an OpenAPI update?

swombat avatar Sep 05 '24 06:09 swombat

PETOSS-571

github-actions[bot] avatar Sep 05 '24 06:09 github-actions[bot]

Thanks for raising an issue, a ticket has been created to track your request

github-actions[bot] avatar Sep 05 '24 06:09 github-actions[bot]

Looking at accounting_api.rb:

    def get_accounts(xero_tenant_id, opts = {})
      data, _status_code, _headers = get_accounts_with_http_info(xero_tenant_id, opts)
      data
    end

It appears the docs are wrong.

    def get_accounts_with_http_info(xero_tenant_id, options = {})
      opts = options.dup
(...)
      opts[:'where'] = @api_client.parameterize_where(opts[:'where']) if !opts[:'where'].nil?

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'where'] = opts[:'where'] if !opts[:'where'].nil?
      query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?

      # XeroAPI's `IDs` convention openapi-generator does not snake_case properly.. manual over-riding `i_ds` malformations:
      query_params[:'IDs'] = @api_client.build_collection_param(opts[:'ids'], :csv) if !opts[:'ids'].nil?
      query_params[:'ContactIDs'] = @api_client.build_collection_param(opts[:'contact_ids'], :csv) if !opts[:'contact_ids'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      header_params[:'xero-tenant-id'] = xero_tenant_id
      header_params[:'If-Modified-Since'] = opts[:'if_modified_since'] if !opts[:'if_modified_since'].nil?

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:body]

      # return_type
      return_type = opts[:return_type] || 'Accounts'

      # auth_names
      auth_names = opts[:auth_names] || ['OAuth2']

Seems to me the docs should list the valid options as a hash with keys: :where, :order, :ids, :contact_ids, :header_params, :if_modified_since, :form_params, :body, :return_type, :auth_names.

swombat avatar Sep 05 '24 06:09 swombat