Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect documentation - if_modified_since, where, order #303

Open
swombat opened this issue Sep 5, 2024 · 3 comments
Open

Incorrect documentation - if_modified_since, where, order #303

swombat opened this issue Sep 5, 2024 · 3 comments

Comments

@swombat
Copy link

swombat commented Sep 5, 2024

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?

Copy link

github-actions bot commented Sep 5, 2024

PETOSS-571

Copy link

github-actions bot commented Sep 5, 2024

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

@swombat
Copy link
Author

swombat commented Sep 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant