Skip to content

Commit

Permalink
Fix constant duplication (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkopac authored Jul 8, 2024
1 parent dbfc98d commit cf1ddb0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
/tmp/
*.swp
vendor/bundle
/.idea
/.idea
.ruby-version
6 changes: 3 additions & 3 deletions lib/chartmogul/csv/line_items/one_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
module ChartMogul
module CSV
module LineItems
ONE_TIME_HEADERS = %w[Invoice\ external\ ID External\ ID Subscription\ external\ ID Subscription\ set\ external\ ID Type Amount\ in\ cents Plan Service\ period\ start Service\ period\ end Quantity Proration Discount\ code Discount\ amount Tax\ amount Description Transaction\ fee Account\ Code Transaction\ fees\ currency Discount\ description Balance\ transfer].freeze

class OneTime < Base
HEADERS = %w[Invoice\ external\ ID External\ ID Subscription\ external\ ID Subscription\ set\ external\ ID Type Amount\ in\ cents Plan Service\ period\ start Service\ period\ end Quantity Proration Discount\ code Discount\ amount Tax\ amount Description Transaction\ fee Account\ Code Transaction\ fees\ currency Discount\ description Balance\ transfer].freeze

writeable_attr :invoice_external_id
writeable_attr :external_id
writeable_attr :subscription_external_id
Expand All @@ -32,7 +32,7 @@ def type
end

def self.headers
ChartMogul::CSV::LineItems::ONE_TIME_HEADERS
HEADERS
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/chartmogul/csv/line_items/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
module ChartMogul
module CSV
module LineItems
# from https://chartmogul-samples.s3-eu-west-1.amazonaws.com/public/04_Invoice_line_items.csv
SUBSCRIPTION_HEADERS = %w[Invoice\ external\ ID External\ ID Subscription\ external\ ID Subscription\ set\ external\ ID Type Amount\ in\ cents Plan Service\ period\ start Service\ period\ end Quantity Proration Discount\ code Discount\ amount Tax\ amount Description Transaction\ fee Account\ Code Transaction\ fees\ currency Discount\ description Proration\ type Event\ Order].freeze

class Subscription < Base
# from https://chartmogul-samples.s3-eu-west-1.amazonaws.com/public/04_Invoice_line_items.csv
HEADERS = %w[Invoice\ external\ ID External\ ID Subscription\ external\ ID Subscription\ set\ external\ ID Type Amount\ in\ cents Plan Service\ period\ start Service\ period\ end Quantity Proration Discount\ code Discount\ amount Tax\ amount Description Transaction\ fee Account\ Code Transaction\ fees\ currency Discount\ description Proration\ type Event\ Order].freeze

writeable_attr :invoice_external_id
writeable_attr :external_id
writeable_attr :subscription_external_id
Expand Down Expand Up @@ -34,7 +34,7 @@ def type
end

def self.headers
ChartMogul::CSV::LineItems::SUBSCRIPTION_HEADERS
HEADERS
end
end
end
Expand Down
6 changes: 1 addition & 5 deletions lib/chartmogul/csv/line_items/trial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
module ChartMogul
module CSV
module LineItems
# from https://chartmogul-samples.s3-eu-west-1.amazonaws.com/public/04_Invoice_line_items.csv
SUBSCRIPTION_HEADERS = ['Invoice external ID', 'External ID', 'Subscription external ID',
'Subscription set external ID', 'Type', 'Amount in cents', 'Plan', 'Service period start', 'Service period end', 'Quantity', 'Proration', 'Discount code', 'Discount amount', 'Tax amount', 'Description', 'Transaction fee', 'Account Code', 'Transaction fees currency', 'Discount description', 'Proration type', 'Event Order'].freeze

class Trial < Subscription
writeable_attr :invoice_external_id
writeable_attr :external_id
Expand Down Expand Up @@ -35,7 +31,7 @@ def type
end

def self.headers
ChartMogul::CSV::LineItems::SUBSCRIPTION_HEADERS
HEADERS
end
end
end
Expand Down

0 comments on commit cf1ddb0

Please sign in to comment.