effective_qb_sync 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 319c4615761c91d7f339bc221173660689d618c93d31a97eb0fda7c0fd1c4119
4
- data.tar.gz: bb82bd7bfdaf8e996f901c96e682a3e03be6da829fd85f298365f9632cdc27bc
3
+ metadata.gz: 2eef5621d3a64765720af65734b135ba35bf5433a509c1ad39510b374a4ff95c
4
+ data.tar.gz: 2f3c34d7e2b3dad8878666649d5e167f0433aedd26479e349a38edd0e304276b
5
5
  SHA512:
6
- metadata.gz: dddb2b8fdd4a0087891534bdf96adff2e40c3020661051dc86c46da444b502d8ceae333f517ae356928e3ec22dc4e91067312b23cd04c70e5a4a5ce245911357
7
- data.tar.gz: 3a749c4afe9031557d936c5f76aedf40a7331098bbd16d3a9ab0271043bb1bfc89dd3a1e662dd14a26a7e7f503d8029c88c5127759862486d6bdb280060cf3bd
6
+ metadata.gz: b9ff3bd819af28527bfa88b784d2bc4667e0057924da6627c1f67a136f7efb0dc412ffa675aa29ba67d2d66147ad12378a269f558ea1799f8d9b0362e919746b
7
+ data.tar.gz: cf82590efa8276942f285029fe46f45f04b90fa67aa951b05acc82c02bcb971a630c65439ce450515f63bc815e865003f4f8aabcefb08eac2623105c947daccf
@@ -27,17 +27,17 @@ module Effective
27
27
 
28
28
  unless authentication_valid?(username, password)
29
29
  log "Authentication failed for user #{username}"
30
- @ticket.update_attributes!(username: username, state: 'Finished', last_error: @last_log_message)
30
+ @ticket.update!(username: username, state: 'Finished', last_error: @last_log_message)
31
31
  return 'nvu' # not valid user
32
32
  end
33
33
 
34
34
  if has_work?
35
35
  log "Authentication successful. Reporting to QuickBooks that there is work to be done."
36
- @ticket.update_attributes!(username: username, state: 'Authenticated')
36
+ @ticket.update!(username: username, state: 'Authenticated')
37
37
  '' # "Any other string value = use this name for company file"
38
38
  else
39
39
  log "Authentication successful, but there is no work to be done"
40
- @ticket.update_attributes!(username: username, state: 'Finished')
40
+ @ticket.update!(username: username, state: 'Finished')
41
41
  'none'
42
42
  end
43
43
  end
@@ -58,7 +58,7 @@ module Effective
58
58
  return '' unless valid?
59
59
 
60
60
  # update the ticket with the metadata sent at the first request for XML (i.e. if not blank)
61
- @ticket.update_attributes!(
61
+ @ticket.update!(
62
62
  hpc_response: (@ticket.hpc_response || params[:hcpresponse]),
63
63
  company_file_name: (@ticket.company_file_name || params[:company]),
64
64
  country: (@ticket.country || params[:country]),
@@ -82,13 +82,13 @@ module Effective
82
82
  # if we don't have a request, then we are done.
83
83
  unless request
84
84
  log "There is no more work to be done. Marking ticket state as finished"
85
- @ticket.update_attributes!(state: 'Finished')
85
+ @ticket.update!(state: 'Finished')
86
86
  return ''
87
87
  end
88
88
 
89
- request.update_attributes!(qb_ticket: @ticket, request_sent_at: Time.zone.now)
89
+ request.update!(qb_ticket: @ticket, request_sent_at: Time.zone.now)
90
90
  qb_xml = request.to_qb_xml
91
- request.update_attributes!(request_qbxml: qb_xml)
91
+ request.update!(request_qbxml: qb_xml)
92
92
 
93
93
  # set the ticket into a Processing state
94
94
  @ticket.state = 'Processing'
@@ -134,7 +134,7 @@ module Effective
134
134
 
135
135
  # also update the request if it is able to be found
136
136
  request = find_outstanding_request(responseXML)
137
- request.update_attributes!(response_qbxml: responseXML, state: 'Error') if request
137
+ request.update!(response_qbxml: responseXML, state: 'Error') if request
138
138
 
139
139
  return -1
140
140
  end
@@ -161,12 +161,12 @@ module Effective
161
161
  unless request.consume_response_xml(responseXML)
162
162
  # this request for some reason did not succeeed. Update the request and the ticket
163
163
  log "Request [#{request.state}] could not process the QuickBooks response: #{request.error}"
164
- request.update_attributes!(response_qbxml: responseXML, state: 'Error')
164
+ request.update!(response_qbxml: responseXML, state: 'Error')
165
165
  @ticket.error! @last_log_message
166
166
  return -1
167
167
  end
168
168
 
169
- request.update_attributes!(response_qbxml: responseXML) # This was changed for effective_qb_sync
169
+ request.update!(response_qbxml: responseXML) # This was changed for effective_qb_sync
170
170
 
171
171
  # the request has processed the response XML. if it does not have any more work to do, then detach it
172
172
 
@@ -174,7 +174,7 @@ module Effective
174
174
  log "Request [#{request.state}] has more work to do on the next request"
175
175
  else
176
176
  # detach the current request
177
- @ticket.update_attributes!(qb_request: nil)
177
+ @ticket.update!(qb_request: nil)
178
178
  log "Request [#{request.state}] has completed its work"
179
179
  end
180
180
 
@@ -214,7 +214,7 @@ module Effective
214
214
  def op_close_connection
215
215
  return 'Close error: invalid ticket' unless valid?
216
216
 
217
- @ticket.update_attributes!(state: 'Finished') unless ['ConnectionError', 'RequestError'].include?(@ticket.state)
217
+ @ticket.update!(state: 'Finished') unless ['ConnectionError', 'RequestError'].include?(@ticket.state)
218
218
  log "Closed connection with QuickBooks"
219
219
 
220
220
  'OK'
@@ -63,7 +63,7 @@ module Effective
63
63
  # parses the response XML and processes it.
64
64
  # returns true if the responseXML indicates success, false otherwise
65
65
  def consume_response_xml(xml)
66
- update_attributes!(response_qbxml: xml)
66
+ update!(response_qbxml: xml)
67
67
  handle_response_xml(xml)
68
68
  end
69
69
 
@@ -116,7 +116,7 @@ module Effective
116
116
  # transitions the request state and also outputs a log statement
117
117
  def transition_state(state)
118
118
  old_state = self.state
119
- update_attributes!(state: state)
119
+ update!(state: state)
120
120
  log "Transitioned request state from [#{old_state}] to [#{state}]"
121
121
  end
122
122
 
@@ -1,6 +1,6 @@
1
1
  module Effective
2
2
  class QbTicket < ActiveRecord::Base
3
- belongs_to :qb_request # the current request
3
+ belongs_to :qb_request, optional: true # the current request. Only optional when set_all_orders_finished
4
4
  has_many :qb_requests
5
5
  has_many :orders, through: :qb_requests
6
6
  has_many :qb_logs
@@ -15,7 +15,7 @@ module Effective
15
15
  qbxml_major_version :string
16
16
  qbxml_minor_version :string
17
17
 
18
- state :string, default: 'Ready'
18
+ state :string # , default: 'Ready'
19
19
  percent :integer
20
20
 
21
21
  hpc_response :text
@@ -31,7 +31,7 @@ module Effective
31
31
  validates :state, inclusion: { in: STATES }
32
32
 
33
33
  def request_error!(error, atts={})
34
- self.error!(error, atts.reverse_merge({state: 'RequestError'}))
34
+ self.error!(error, atts.reverse_merge(state: 'RequestError'))
35
35
  end
36
36
 
37
37
  # This is the entry point for a standard error.
@@ -44,7 +44,7 @@ module Effective
44
44
  template: 'qb_sync_error'
45
45
  ).public_send(EffectiveOrders.mailer[:deliver_method])
46
46
 
47
- self.update_attributes!(atts.reverse_merge({last_error: error}))
47
+ update!(atts.reverse_merge(last_error: error))
48
48
  end
49
49
 
50
50
  # persists a new log message to this ticket
@@ -1,3 +1,3 @@
1
1
  module EffectiveQbSync
2
- VERSION = '1.3.1'.freeze
2
+ VERSION = '1.3.2'.freeze
3
3
  end
@@ -209,7 +209,7 @@ describe Effective::QbMachine, "Sending Request qbXML to QuickBooks (op_send_req
209
209
  end
210
210
 
211
211
  it "should transition ticket to the RequestError state if the ticket is not in the Authenticated or Processing states" do
212
- @qb_machine.ticket.update_attributes!(state: 'Finished')
212
+ @qb_machine.ticket.update!(state: 'Finished')
213
213
  @qb_machine.op_send_request_xml(@default_request_params)
214
214
  @qb_machine.ticket.state.should eql('RequestError')
215
215
  end
@@ -314,25 +314,25 @@ describe Effective::QbMachine, "Receiving response qbXML from QuickBooks (op_rec
314
314
  end
315
315
 
316
316
  it "should return -1 to indicate error if the ticket state is not in the Processing state" do
317
- @qb_machine.ticket.update_attributes! :state=>'Finished'
317
+ @qb_machine.ticket.update! :state=>'Finished'
318
318
  result = @qb_machine.op_receive_response_xml(@default_response_params)
319
319
  result.should eql(-1)
320
320
  end
321
321
 
322
322
  it "should set the ticket state to RequestError if the ticket state was previously Authenticated" do
323
- @qb_machine.ticket.update_attributes! :state=>'Authenticated'
323
+ @qb_machine.ticket.update! :state=>'Authenticated'
324
324
  @qb_machine.op_receive_response_xml(@default_response_params)
325
325
  @qb_machine.ticket.state.should eql('RequestError')
326
326
  end
327
327
 
328
328
  it "should set the ticket state to RequestError if the ticket state was previously Ready" do
329
- @qb_machine.ticket.update_attributes! :state=>'Ready'
329
+ @qb_machine.ticket.update! :state=>'Ready'
330
330
  @qb_machine.op_receive_response_xml(@default_response_params)
331
331
  @qb_machine.ticket.state.should eql('RequestError')
332
332
  end
333
333
 
334
334
  it "should set the ticket state to RequestError if the ticket state was previously Finished" do
335
- @qb_machine.ticket.update_attributes! :state=>'Finished'
335
+ @qb_machine.ticket.update! :state=>'Finished'
336
336
  @qb_machine.op_receive_response_xml(@default_response_params)
337
337
  @qb_machine.ticket.state.should eql('RequestError')
338
338
  end
@@ -487,7 +487,7 @@ describe Effective::QbMachine, "Receiving a request from the QBWC to provide the
487
487
  before :each do
488
488
  @qb_machine = Effective::QbMachine.new
489
489
  @last_error = 'What?'
490
- @qb_machine.ticket.update_attributes! :last_error=>@last_error
490
+ @qb_machine.ticket.update! :last_error=>@last_error
491
491
  end
492
492
 
493
493
  it "should return the last error" do
@@ -495,11 +495,11 @@ describe Effective::QbMachine, "Receiving a request from the QBWC to provide the
495
495
  end
496
496
 
497
497
  it "should return '' if the last error is blank" do
498
- @qb_machine.ticket.update_attributes! :last_error=>nil
498
+ @qb_machine.ticket.update! :last_error=>nil
499
499
  error = @qb_machine.op_last_error
500
500
  error.should eql('')
501
501
 
502
- @qb_machine.ticket.update_attributes! :last_error=>''
502
+ @qb_machine.ticket.update! :last_error=>''
503
503
  error = @qb_machine.op_last_error
504
504
  error.should eql('')
505
505
  end
@@ -513,42 +513,40 @@ describe Effective::QbMachine, "Closing the connection (op_close_connection)" do
513
513
  end
514
514
 
515
515
  it "should not transition ticket state on close_connection if state is Finished" do
516
- @qb_machine.ticket.update_attributes! :state=>'Finished'
516
+ @qb_machine.ticket.update! :state=>'Finished'
517
517
  @qb_machine.op_close_connection
518
518
  @qb_machine.ticket.state.should eql('Finished')
519
519
  end
520
520
 
521
521
  it "should not transition ticket state on close_connection if state is ConnectionError" do
522
- @qb_machine.ticket.update_attributes! :state=>'ConnectionError'
522
+ @qb_machine.ticket.update! :state=>'ConnectionError'
523
523
  @qb_machine.op_close_connection
524
524
  @qb_machine.ticket.state.should eql('ConnectionError')
525
525
  end
526
526
 
527
527
  it "should not transition ticket state on close_connection if state is RequestError" do
528
- @qb_machine.ticket.update_attributes! :state=>'RequestError'
528
+ @qb_machine.ticket.update! :state=>'RequestError'
529
529
  @qb_machine.op_close_connection
530
530
  @qb_machine.ticket.state.should eql('RequestError')
531
531
  end
532
532
 
533
533
  it "should transition ticket state to Finished if state is Ready " do
534
- @qb_machine.ticket.update_attributes! :state=>'Ready'
534
+ @qb_machine.ticket.update! :state=>'Ready'
535
535
  @qb_machine.op_close_connection
536
536
  @qb_machine.ticket.state.should eql('Finished')
537
537
  end
538
538
 
539
539
  it "should transition ticket state to Finished if state is Authenticated" do
540
- @qb_machine.ticket.update_attributes! :state=>'Authenticated'
540
+ @qb_machine.ticket.update! :state=>'Authenticated'
541
541
  @qb_machine.op_close_connection
542
542
  @qb_machine.ticket.state.should eql('Finished')
543
543
  end
544
544
 
545
545
  it "should transition ticket state to Finished if state is Processing" do
546
- @qb_machine.ticket.update_attributes! :state=>'Processing'
546
+ @qb_machine.ticket.update! :state=>'Processing'
547
547
  @qb_machine.op_close_connection
548
548
  @qb_machine.ticket.state.should eql('Finished')
549
549
  end
550
550
 
551
551
 
552
552
  end
553
-
554
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_qb_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect