-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tax-integrations): update anrok error webhook attributes (#2497)
## Context Integration with tax provider Anrok is being implemented ## Description This PR fixes error webhook that is being dispatched
- Loading branch information
1 parent
b4d4987
commit a5db8cf
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
app/serializers/v1/integrations/taxes/customer_error_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module V1 | ||
module Integrations | ||
module Taxes | ||
class CustomerErrorSerializer < ModelSerializer | ||
def serialize | ||
{ | ||
lago_customer_id: model.id, | ||
external_customer_id: model.external_id, | ||
tax_provider: options[:provider], | ||
tax_provider_code: options[:provider_code], | ||
provider_error: options[:provider_error] | ||
} | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
spec/serializers/v1/integrations/taxes/customer_error_serializer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe ::V1::Integrations::Taxes::CustomerErrorSerializer do | ||
subject(:serializer) { described_class.new(customer, options) } | ||
|
||
let(:integration_customer) { create(:netsuite_customer) } | ||
let(:customer) { integration_customer.customer } | ||
let(:options) do | ||
{ | ||
'provider_error' => { | ||
'error_message' => 'message', | ||
'error_code' => 'code' | ||
}, | ||
'provider' => 'netsuite', | ||
'provider_code' => integration_customer.integration.code | ||
}.with_indifferent_access | ||
end | ||
|
||
it 'serializes the object' do | ||
result = JSON.parse(serializer.to_json) | ||
|
||
aggregate_failures do | ||
expect(result['data']['lago_customer_id']).to eq(customer.id) | ||
expect(result['data']['external_customer_id']).to eq(customer.external_id) | ||
expect(result['data']['tax_provider']).to eq(options[:provider]) | ||
expect(result['data']['tax_provider_code']).to eq(integration_customer.integration.code) | ||
expect(result['data']['provider_error']).to eq(options[:provider_error]) | ||
end | ||
end | ||
end |