xero-ruby 2.8.2 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,7 +31,8 @@ module XeroRuby
31
31
  # @param project_create_or_update [ProjectCreateOrUpdate] Create a new project with ProjectCreateOrUpdate object
32
32
  # @param [Hash] opts the optional parameters
33
33
  # @return [Array<(Project, Integer, Hash)>] Project data, response status code and response headers
34
- def create_project_with_http_info(xero_tenant_id, project_create_or_update, opts = {})
34
+ def create_project_with_http_info(xero_tenant_id, project_create_or_update, options = {})
35
+ opts = options.dup
35
36
  if @api_client.config.debugging
36
37
  @api_client.config.logger.debug 'Calling API: ProjectApi.create_project ...'
37
38
  end
@@ -111,7 +112,8 @@ module XeroRuby
111
112
  # @param time_entry_create_or_update [TimeEntryCreateOrUpdate] The time entry object you are creating
112
113
  # @param [Hash] opts the optional parameters
113
114
  # @return [Array<(TimeEntry, Integer, Hash)>] TimeEntry data, response status code and response headers
114
- def create_time_entry_with_http_info(xero_tenant_id, project_id, time_entry_create_or_update, opts = {})
115
+ def create_time_entry_with_http_info(xero_tenant_id, project_id, time_entry_create_or_update, options = {})
116
+ opts = options.dup
115
117
  if @api_client.config.debugging
116
118
  @api_client.config.logger.debug 'Calling API: ProjectApi.create_time_entry ...'
117
119
  end
@@ -195,7 +197,8 @@ module XeroRuby
195
197
  # @param time_entry_id [String] You can specify an individual task by appending the id to the endpoint
196
198
  # @param [Hash] opts the optional parameters
197
199
  # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
198
- def delete_time_entry_with_http_info(xero_tenant_id, project_id, time_entry_id, opts = {})
200
+ def delete_time_entry_with_http_info(xero_tenant_id, project_id, time_entry_id, options = {})
201
+ opts = options.dup
199
202
  if @api_client.config.debugging
200
203
  @api_client.config.logger.debug 'Calling API: ProjectApi.delete_time_entry ...'
201
204
  end
@@ -273,7 +276,8 @@ module XeroRuby
273
276
  # @param project_id [String] You can specify an individual project by appending the projectId to the endpoint
274
277
  # @param [Hash] opts the optional parameters
275
278
  # @return [Array<(Project, Integer, Hash)>] Project data, response status code and response headers
276
- def get_project_with_http_info(xero_tenant_id, project_id, opts = {})
279
+ def get_project_with_http_info(xero_tenant_id, project_id, options = {})
280
+ opts = options.dup
277
281
  if @api_client.config.debugging
278
282
  @api_client.config.logger.debug 'Calling API: ProjectApi.get_project ...'
279
283
  end
@@ -351,7 +355,8 @@ module XeroRuby
351
355
  # @option opts [Integer] :page set to 1 by default. The requested number of the page in paged response - Must be a number greater than 0.
352
356
  # @option opts [Integer] :page_size Optional, it is set to 50 by default. The number of items to return per page in a paged response - Must be a number between 1 and 500.
353
357
  # @return [Array<(ProjectUsers, Integer, Hash)>] ProjectUsers data, response status code and response headers
354
- def get_project_users_with_http_info(xero_tenant_id, opts = {})
358
+ def get_project_users_with_http_info(xero_tenant_id, options = {})
359
+ opts = options.dup
355
360
  if @api_client.config.debugging
356
361
  @api_client.config.logger.debug 'Calling API: ProjectApi.get_project_users ...'
357
362
  end
@@ -441,7 +446,8 @@ module XeroRuby
441
446
  # @option opts [Integer] :page set to 1 by default. The requested number of the page in paged response - Must be a number greater than 0.
442
447
  # @option opts [Integer] :page_size Optional, it is set to 50 by default. The number of items to return per page in a paged response - Must be a number between 1 and 500.
443
448
  # @return [Array<(Projects, Integer, Hash)>] Projects data, response status code and response headers
444
- def get_projects_with_http_info(xero_tenant_id, opts = {})
449
+ def get_projects_with_http_info(xero_tenant_id, options = {})
450
+ opts = options.dup
445
451
  if @api_client.config.debugging
446
452
  @api_client.config.logger.debug 'Calling API: ProjectApi.get_projects ...'
447
453
  end
@@ -528,7 +534,8 @@ module XeroRuby
528
534
  # @param task_id [String] You can specify an individual task by appending the taskId to the endpoint, i.e. GET https://.../tasks/{taskID}
529
535
  # @param [Hash] opts the optional parameters
530
536
  # @return [Array<(Task, Integer, Hash)>] Task data, response status code and response headers
531
- def get_task_with_http_info(xero_tenant_id, project_id, task_id, opts = {})
537
+ def get_task_with_http_info(xero_tenant_id, project_id, task_id, options = {})
538
+ opts = options.dup
532
539
  if @api_client.config.debugging
533
540
  @api_client.config.logger.debug 'Calling API: ProjectApi.get_task ...'
534
541
  end
@@ -616,7 +623,8 @@ module XeroRuby
616
623
  # @option opts [String] :task_ids taskIdsSearch for all tasks that match a comma separated list of taskIds, i.e. GET https://.../tasks?taskIds&#x3D;{taskID},{taskID}
617
624
  # @option opts [ChargeType] :charge_type
618
625
  # @return [Array<(Tasks, Integer, Hash)>] Tasks data, response status code and response headers
619
- def get_tasks_with_http_info(xero_tenant_id, project_id, opts = {})
626
+ def get_tasks_with_http_info(xero_tenant_id, project_id, options = {})
627
+ opts = options.dup
620
628
  if @api_client.config.debugging
621
629
  @api_client.config.logger.debug 'Calling API: ProjectApi.get_tasks ...'
622
630
  end
@@ -716,7 +724,8 @@ module XeroRuby
716
724
  # @option opts [DateTime] :date_after_utc ISO 8601 UTC date. Finds all time entries on or after this date filtered on the &#x60;dateUtc&#x60; field.
717
725
  # @option opts [DateTime] :date_before_utc ISO 8601 UTC date. Finds all time entries on or before this date filtered on the &#x60;dateUtc&#x60; field.
718
726
  # @return [Array<(TimeEntries, Integer, Hash)>] TimeEntries data, response status code and response headers
719
- def get_time_entries_with_http_info(xero_tenant_id, project_id, opts = {})
727
+ def get_time_entries_with_http_info(xero_tenant_id, project_id, options = {})
728
+ opts = options.dup
720
729
  if @api_client.config.debugging
721
730
  @api_client.config.logger.debug 'Calling API: ProjectApi.get_time_entries ...'
722
731
  end
@@ -804,7 +813,8 @@ module XeroRuby
804
813
  # @param time_entry_id [String] You can specify an individual time entry by appending the id to the endpoint
805
814
  # @param [Hash] opts the optional parameters
806
815
  # @return [Array<(TimeEntry, Integer, Hash)>] TimeEntry data, response status code and response headers
807
- def get_time_entry_with_http_info(xero_tenant_id, project_id, time_entry_id, opts = {})
816
+ def get_time_entry_with_http_info(xero_tenant_id, project_id, time_entry_id, options = {})
817
+ opts = options.dup
808
818
  if @api_client.config.debugging
809
819
  @api_client.config.logger.debug 'Calling API: ProjectApi.get_time_entry ...'
810
820
  end
@@ -886,7 +896,8 @@ module XeroRuby
886
896
  # @param project_patch [ProjectPatch] Update the status of an existing Project
887
897
  # @param [Hash] opts the optional parameters
888
898
  # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
889
- def patch_project_with_http_info(xero_tenant_id, project_id, project_patch, opts = {})
899
+ def patch_project_with_http_info(xero_tenant_id, project_id, project_patch, options = {})
900
+ opts = options.dup
890
901
  if @api_client.config.debugging
891
902
  @api_client.config.logger.debug 'Calling API: ProjectApi.patch_project ...'
892
903
  end
@@ -970,7 +981,8 @@ module XeroRuby
970
981
  # @param project_create_or_update [ProjectCreateOrUpdate] Request of type ProjectCreateOrUpdate
971
982
  # @param [Hash] opts the optional parameters
972
983
  # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
973
- def update_project_with_http_info(xero_tenant_id, project_id, project_create_or_update, opts = {})
984
+ def update_project_with_http_info(xero_tenant_id, project_id, project_create_or_update, options = {})
985
+ opts = options.dup
974
986
  if @api_client.config.debugging
975
987
  @api_client.config.logger.debug 'Calling API: ProjectApi.update_project ...'
976
988
  end
@@ -1056,7 +1068,8 @@ module XeroRuby
1056
1068
  # @param time_entry_create_or_update [TimeEntryCreateOrUpdate] The time entry object you are updating
1057
1069
  # @param [Hash] opts the optional parameters
1058
1070
  # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
1059
- def update_time_entry_with_http_info(xero_tenant_id, project_id, time_entry_id, time_entry_create_or_update, opts = {})
1071
+ def update_time_entry_with_http_info(xero_tenant_id, project_id, time_entry_id, time_entry_create_or_update, options = {})
1072
+ opts = options.dup
1060
1073
  if @api_client.config.debugging
1061
1074
  @api_client.config.logger.debug 'Calling API: ProjectApi.update_time_entry ...'
1062
1075
  end
@@ -32,13 +32,14 @@ module XeroRuby
32
32
 
33
33
  # Initializes the ApiClient
34
34
  # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
35
- def initialize(config: Configuration.default, credentials: {})
35
+ def initialize(config: {}, credentials: {})
36
36
  @client_id = credentials[:client_id]
37
37
  @client_secret = credentials[:client_secret]
38
38
  @redirect_uri = credentials[:redirect_uri]
39
39
  @scopes = credentials[:scopes]
40
40
  @state = credentials[:state]
41
- @config = config
41
+ @config = append_to_default_config(config)
42
+
42
43
  @user_agent = "xero-ruby-#{VERSION}"
43
44
  @default_headers = {
44
45
  'Content-Type' => 'application/json',
@@ -46,6 +47,12 @@ module XeroRuby
46
47
  }
47
48
  end
48
49
 
50
+ def append_to_default_config(user_config)
51
+ config = Configuration.default
52
+ user_config.each{|k,v| config.send("#{k}=", v) } if user_config
53
+ config
54
+ end
55
+
49
56
  def authorization_url
50
57
  url = "#{@config.login_url}?response_type=code&client_id=#{@client_id}&redirect_uri=#{@redirect_uri}&scope=#{CGI.escape(@scopes)}"
51
58
  url << "&state=#{@state}" if @state
@@ -258,6 +265,7 @@ module XeroRuby
258
265
  end
259
266
  end
260
267
  request.headers = header_params
268
+ request.options.timeout = @config.timeout
261
269
  request.body = req_body
262
270
  request.url url
263
271
  request.params = query_params
@@ -46,6 +46,7 @@ module XeroRuby::PayrollUk
46
46
  # The type of the payment of the corresponding salary and wages
47
47
  attr_accessor :payment_type
48
48
  SALARY = "Salary".freeze
49
+ HOURLY = "Hourly".freeze
49
50
 
50
51
  class EnumAttributeValidator
51
52
  attr_reader :datatype
@@ -193,7 +194,7 @@ module XeroRuby::PayrollUk
193
194
  status_validator = EnumAttributeValidator.new('String', ["Active", "Pending", "History"])
194
195
  return false unless status_validator.valid?(@status)
195
196
  return false if @payment_type.nil?
196
- payment_type_validator = EnumAttributeValidator.new('String', ["Salary"])
197
+ payment_type_validator = EnumAttributeValidator.new('String', ["Salary", "Hourly"])
197
198
  return false unless payment_type_validator.valid?(@payment_type)
198
199
  true
199
200
  end
@@ -211,7 +212,7 @@ module XeroRuby::PayrollUk
211
212
  # Custom attribute writer method checking allowed values (enum).
212
213
  # @param [Object] payment_type Object to be assigned
213
214
  def payment_type=(payment_type)
214
- validator = EnumAttributeValidator.new('String', ["Salary"])
215
+ validator = EnumAttributeValidator.new('String', ["Salary", "Hourly"])
215
216
  unless validator.valid?(payment_type)
216
217
  fail ArgumentError, "invalid value for \"payment_type\", must be one of #{validator.allowable_values}."
217
218
  end
@@ -11,5 +11,5 @@ The version of the XeroOpenAPI document: 2.10.4
11
11
  =end
12
12
 
13
13
  module XeroRuby
14
- VERSION = '2.8.2'
14
+ VERSION = '2.9.0'
15
15
  end
@@ -137,6 +137,17 @@ describe XeroRuby::ApiClient do
137
137
  api_client.connections
138
138
  expect(api_client.config.base_url).to eq('https://api.xero.com')
139
139
  end
140
+
141
+ it "does not mutate the original opts hash" do
142
+ expect(api_client).to receive(:call_api).and_return('')
143
+ opts = {
144
+ where: {
145
+ invoice_number: ['=', "INV-0060"]
146
+ }
147
+ }
148
+ api_client.accounting_api.get_invoices('active_tenant_id', opts)
149
+ expect(opts).to eq({:where=>{:invoice_number=>["=", "INV-0060"]}})
150
+ end
140
151
  end
141
152
 
142
153
  describe '#deserialize' do
@@ -16,4 +16,21 @@ describe XeroRuby::Configuration do
16
16
  expect(config.payroll_uk_url).to eq('https://api.xero.com/payroll.xro/2.0/')
17
17
  end
18
18
  end
19
+
20
+ describe 'config' do
21
+ it 'should apply the default configuration options' do
22
+ client = XeroRuby::ApiClient.new(credentials: {})
23
+ expect(client.config.login_url).to eq('https://login.xero.com/identity/connect/authorize')
24
+ end
25
+
26
+ it 'should allow you to overwrite the default configuration options' do
27
+ client = XeroRuby::ApiClient.new(credentials: {}, config: {login_url: 'ngrok.login.xero.test'})
28
+ expect(client.config.login_url).to eq('ngrok.login.xero.test')
29
+ end
30
+
31
+ it 'should allow you to set the timeout config option' do
32
+ client = XeroRuby::ApiClient.new(credentials: {}, config: {timeout: 30})
33
+ expect(client.config.timeout).to eq(30)
34
+ end
35
+ end
19
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xero-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.2
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xero API Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-02 00:00:00.000000000 Z
11
+ date: 2021-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday