From d6f3d67fcf94eae31234d29fc266cffde9349efc Mon Sep 17 00:00:00 2001 From: Seth Brown Date: Tue, 13 Feb 2024 14:27:08 -0500 Subject: [PATCH 1/2] add revrec to shipping methods --- lib/recurly/shipping_method.rb | 2 +- spec/fixtures/shipping_methods/show-200.xml | 3 +++ spec/recurly/shipping_method_spec.rb | 13 +++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/recurly/shipping_method.rb b/lib/recurly/shipping_method.rb index 76d915c14..2f1e45c2e 100644 --- a/lib/recurly/shipping_method.rb +++ b/lib/recurly/shipping_method.rb @@ -7,7 +7,7 @@ class ShippingMethod < Resource tax_code created_at updated_at - ) + ) + RevRec::PRODUCT_ATTRIBUTES alias to_param code end end diff --git a/spec/fixtures/shipping_methods/show-200.xml b/spec/fixtures/shipping_methods/show-200.xml index faac8499b..966956cbe 100644 --- a/spec/fixtures/shipping_methods/show-200.xml +++ b/spec/fixtures/shipping_methods/show-200.xml @@ -6,6 +6,9 @@ Content-Type: application/xml; charset=utf-8 fedex_ground FedEx Ground + twywqfr48v9l + thproqnpcuwp + 4 2019-05-07T16:36:22Z 2019-05-07T16:36:22Z diff --git a/spec/recurly/shipping_method_spec.rb b/spec/recurly/shipping_method_spec.rb index 0e4094383..a805850a2 100644 --- a/spec/recurly/shipping_method_spec.rb +++ b/spec/recurly/shipping_method_spec.rb @@ -2,12 +2,21 @@ describe ShippingMethod do describe ".find" do - it "must return a shipping method when available" do + before do stub_api_request( :get, 'shipping_methods/fedex_ground', 'shipping_methods/show-200' - ) + ) + end + it "must return a shipping method when available" do shipping_method = ShippingMethod.find 'fedex_ground' shipping_method.must_be_instance_of ShippingMethod end + + it "returns RevRec values" do + shipping_method = ShippingMethod.find 'fedex_ground' + shipping_method.performance_obligation_id.must_equal('4') + shipping_method.revenue_gl_account_id.must_equal('thproqnpcuwp') + shipping_method.liability_gl_account_id.must_equal('twywqfr48v9l') + end end end \ No newline at end of file From f28b5aad361dce85146675854bb3036328f4d95e Mon Sep 17 00:00:00 2001 From: Seth Brown Date: Tue, 13 Feb 2024 14:40:25 -0500 Subject: [PATCH 2/2] general refactor for revrec ruby --- lib/recurly/business_entity.rb | 2 -- lib/recurly/plan.rb | 2 -- lib/recurly/resource.rb | 1 + spec/recurly/business_entity_spec.rb | 4 ++-- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/recurly/business_entity.rb b/lib/recurly/business_entity.rb index ce46f9b64..a90ce7b7b 100644 --- a/lib/recurly/business_entity.rb +++ b/lib/recurly/business_entity.rb @@ -1,8 +1,6 @@ module Recurly class BusinessEntity < Resource belongs_to :site - belongs_to :default_revenue_gl_account, class_name: 'GeneralLedgerAccount' - belongs_to :default_liability_gl_account, class_name: 'GeneralLedgerAccount' has_many :invoices has_many :accounts diff --git a/lib/recurly/plan.rb b/lib/recurly/plan.rb index 153ef5bf7..6162dad6d 100644 --- a/lib/recurly/plan.rb +++ b/lib/recurly/plan.rb @@ -1,5 +1,3 @@ -require_relative './rev_rec' - module Recurly # Recurly Documentation: https://dev.recurly.com/docs/list-plans class Plan < Resource diff --git a/lib/recurly/resource.rb b/lib/recurly/resource.rb index 8d93bbb7e..d3c11653a 100644 --- a/lib/recurly/resource.rb +++ b/lib/recurly/resource.rb @@ -1,5 +1,6 @@ require 'date' require 'erb' +require_relative './rev_rec' module Recurly # The base class for all Recurly resources (e.g. {Account}, {Subscription}, diff --git a/spec/recurly/business_entity_spec.rb b/spec/recurly/business_entity_spec.rb index 7b8eabc80..5820436f3 100644 --- a/spec/recurly/business_entity_spec.rb +++ b/spec/recurly/business_entity_spec.rb @@ -43,8 +43,8 @@ subscriber_location_countries: ['US', 'AU'], default_vat_number: '12345', default_registration_number: '12345', - default_revenue_gl_account: revenue_gla, - default_liability_gl_account: liablity_gla, + default_revenue_gl_account_id: revenue_gla.id, + default_liability_gl_account_id: liablity_gla.id, created_at: '2023-05-23T19:02:40Z', updated_at: '2023-06-23T19:02:40Z' )