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

fix(tax-integrations): update anrok error webhook attributes #2497

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/serializers/v1/integrations/taxes/customer_error_serializer.rb
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
2 changes: 1 addition & 1 deletion app/services/webhooks/integrations/taxes/error_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def current_organization
end

def object_serializer
::V1::Integrations::CustomerErrorSerializer.new(
::V1::Integrations::Taxes::CustomerErrorSerializer.new(
object,
root_name: object_type,
provider_error: options[:provider_error],
Expand Down
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