• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kleer-la / eventer / 9324617756

31 May 2024 09:34PM UTC coverage: 67.609% (-0.7%) from 68.348%
9324617756

push

github

jgabardini
circular logs

2104 of 3112 relevant lines covered (67.61%)

7.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

37.5
/app/jobs/xero_web_hook_job.rb
1
class XeroWebHookJob < ActiveJob::Base
1✔
2
  
3
  queue_as :default
1✔
4

5
  def initialize(xero_client = nil)
1✔
6
    super
×
7
    @xero_client = xero_client || XeroClientService.create_xero
×
8
  end
9
# ccb1c26d-0113-47e2-826e-a9b1429b1a78 unpaid
10
# 6f352e28-585f-4ccd-a952-560a8f0e5af0 paid // AmountPaid
11
# a61366ff-a7f3-4da2-9a4e-01bc9c54ef9e // status VOIDED
12
# 
13
# hook{"events":[{
14
#    "resourceUrl": "https://api.xero.com/api.xro/2.0/Invoices/ccb1c26d-0113-47e2-826e-a9b1429b1a78",
15
#      "resourceId": "ccb1c26d-0113-47e2-826e-a9b1429b1a78",
16
#      "tenantId": "6acd215c-fade-488f-81cb-d861052c46e8",
17
#      "tenantType": "ORGANISATION",
18
#      "eventCategory": "INVOICE",
19
#      "eventType": "UPDATE",
20
#      "eventDateUtc": "2022-12-07T17:32:56.478"
21
#    }],"firstEventSequence": 1,"lastEventSequence": 1, "entropy": "RJMDNODUDRNVADNQUWVC"}
22

23
def perform(data)
1✔
24
    # runner = XeroApiRunner.new('Automatización desde Xero')
25

26
    # ret_val = runner.execute do |api_run|
27
      data['events'].each do |event|
×
28
        Log.log(:xero, :info, 'Procesando webhook job', event.to_s) if Setting.get(:LOG_LEVEL).to_i > 1
×
29

30
        next if event['tenantId'] != @xero_client.tenant_id
×
31

32
        if invoice_update?(event)
×
33
          Log.log(:xero, :info, 'webhook invoice', event.to_s) if Setting.get(:LOG_LEVEL).to_i > 0
×
34
          ParticipantsController.update_payment_status(event['resourceId'], @xero_client)
×
35
        else
36
          Log.log(:xero, :info, 'Saliendo por tipo de evento no procesado', event.to_s) if Setting.get(:LOG_LEVEL).to_i > 1
×
37
        end
38
      end
39

40
    # raise 'Internal error processing webhook handler' unless ret_val
41
  end
42

43
  private
1✔
44

45
  def invoice_update?(event)
1✔
46
    event['eventCategory'] == 'INVOICE' && event['eventType'] == 'UPDATE'
×
47
  end
48
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc