XeroAPI / xero-ruby

Xero Ruby SDK for OAuth 2.0 generated from XeroAPI/Xero-OpenAPI
http://developer.xero.com/
MIT License
58 stars 91 forks source link

Incorrect documentation - if_modified_since, where, order #303

Open swombat opened 2 months ago

swombat commented 2 months ago

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?

github-actions[bot] commented 2 months ago

PETOSS-571

github-actions[bot] commented 2 months ago

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

swombat commented 2 months ago

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.