Skip to content

Commit

Permalink
Add more objects (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
jared-invoiced authored Jan 31, 2022
1 parent 0340210 commit 7374914
Show file tree
Hide file tree
Showing 38 changed files with 513 additions and 3 deletions.
41 changes: 39 additions & 2 deletions lib/invoiced.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

require 'invoiced/object'
require 'invoiced/payment_source_object'

require 'invoiced/attachment'
require 'invoiced/bank_account'
require 'invoiced/card'
Expand All @@ -27,25 +28,43 @@
require 'invoiced/coupon'
require 'invoiced/credit_balance_adjustment'
require 'invoiced/credit_note'
require 'invoiced/custom_field'
require 'invoiced/customer'
require 'invoiced/customer_chasing_cadence'
require 'invoiced/email'
require 'invoiced/email_template'
require 'invoiced/estimate'
require 'invoiced/event'
require 'invoiced/file'
require 'invoiced/gl_account'
require 'invoiced/inbox'
require 'invoiced/invoice'
require 'invoiced/invoice_chasing_cadence'
require 'invoiced/item'
require 'invoiced/late_fee_schedule'
require 'invoiced/letter'
require 'invoiced/line_item'
require 'invoiced/member'
require 'invoiced/merchant_account'
require 'invoiced/note'
require 'invoiced/payment'
require 'invoiced/payment_method'
require 'invoiced/payment_plan'
require 'invoiced/payment_source'
require 'invoiced/pdf_template'
require 'invoiced/plan'
require 'invoiced/refund'
require 'invoiced/report'
require 'invoiced/role'
require 'invoiced/sign_up_page'
require 'invoiced/sms_template'
require 'invoiced/subscription'
require 'invoiced/task'
require 'invoiced/tax_rate'
require 'invoiced/tax_rule'
require 'invoiced/text_message'
require 'invoiced/theme'
require 'invoiced/webhook'

module Invoiced
class Client
Expand All @@ -56,7 +75,7 @@ class Client
ReadTimeout = 80

attr_reader :api_key, :api_url, :sandbox, :sso_key
attr_reader :Item, :Charge, :Coupon, :CreditBalanceAdjustment, :CreditNote, :Customer, :Estimate, :Event, :File, :Invoice, :Note, :Payment, :Plan, :Refund, :Subscription, :Task, :TaxRate
attr_reader :Charge, :Coupon, :CreditBalanceAdjustment, :CreditNote, :CustomField, :Customer, :CustomerChasingCadence, :EmailTemplate, :Estimate, :Event, :File, :GlAccount, :Inbox, :Invoice, :InvoiceChasingCadence, :Item, :LateFeeSchedule, :Member, :MerchantAccount, :Note, :Payment, :PaymentMethod, :PdfTemplate, :Plan, :Refund, :Report, :Role, :SignUpPage, :SmsTemplate, :Subscription, :Task, :TaxRate, :TaxRule, :Theme, :Webhook

def initialize(api_key, sandbox=false, sso_key=false)
@api_key = api_key
Expand All @@ -65,23 +84,41 @@ def initialize(api_key, sandbox=false, sso_key=false)
@sso_key = sso_key

# Object endpoints
@Item = Invoiced::Item.new(self)
@Charge = Invoiced::Charge.new(self)
@Coupon = Invoiced::Coupon.new(self)
@CreditBalanceAdjustment = Invoiced::CreditBalanceAdjustment.new(self)
@CreditNote = Invoiced::CreditNote.new(self)
@CustomField = Invoiced::CustomField.new(self)
@Customer = Invoiced::Customer.new(self)
@CustomerChasingCadence = Invoiced::CustomerChasingCadence.new(self)
@EmailTemplate = Invoiced::EmailTemplate.new(self)
@Estimate = Invoiced::Estimate.new(self)
@Event = Invoiced::Event.new(self)
@File = Invoiced::File.new(self)
@GlAccount = Invoiced::GlAccount.new(self)
@Inbox = Invoiced::Inbox.new(self)
@Invoice = Invoiced::Invoice.new(self)
@InvoiceChasingCadence = Invoiced::InvoiceChasingCadence.new(self)
@Item = Invoiced::Item.new(self)
@LateFeeSchedule = Invoiced::LateFeeSchedule.new(self)
@Member = Invoiced::Member.new(self)
@MerchantAccount = Invoiced::MerchantAccount.new(self)
@Note = Invoiced::Note.new(self)
@Payment = Invoiced::Payment.new(self)
@PaymentMethod = Invoiced::PaymentMethod.new(self)
@PdfTemplate = Invoiced::PdfTemplate.new(self)
@Plan = Invoiced::Plan.new(self)
@Refund = Invoiced::Refund.new(self)
@Report = Invoiced::Report.new(self)
@Role = Invoiced::Role.new(self)
@SignUpPage = Invoiced::SignUpPage.new(self)
@SmsTemplate = Invoiced::SmsTemplate.new(self)
@Subscription = Invoiced::Subscription.new(self)
@Task = Invoiced::Task.new(self)
@TaxRate = Invoiced::TaxRate.new(self)
@TaxRule = Invoiced::TaxRule.new(self)
@Theme = Invoiced::Theme.new(self)
@Webhook = Invoiced::Webhook.new(self)
end

def request(method, endpoint, params={}, opts={})
Expand Down
10 changes: 10 additions & 0 deletions lib/invoiced/custom_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class CustomField < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'custom_field'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/customer_chasing_cadence.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class CustomerChasingCadence < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'customer_chasing_cadence'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/email_template.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class EmailTemplate < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'email_template'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/gl_account.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class GlAccount < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'gl_account'
end
end
7 changes: 7 additions & 0 deletions lib/invoiced/inbox.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Invoiced
class Inbox < Object
include Invoiced::Operations::List

OBJECT_NAME = 'inbox'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/invoice_chasing_cadence.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class InvoiceChasingCadence < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'invoice_chasing_cadence'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/late_fee_schedule.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class LateFeeSchedule < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'late_fee_schedule'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/member.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class Member < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'member'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/merchant_account.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class MerchantAccount < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'merchant_account'
end
end
6 changes: 5 additions & 1 deletion lib/invoiced/object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ def endpoint()

def build_endpoint
if self.class.const_defined? "OBJECT_NAME"
'/' + self.class::OBJECT_NAME + 's'
if self.class::OBJECT_NAME == 'inbox'
'/inboxes'
else
'/' + self.class::OBJECT_NAME + 's'
end
else
'/objects'
end
Expand Down
8 changes: 8 additions & 0 deletions lib/invoiced/payment_method.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Invoiced
class PaymentMethod < Object
include Invoiced::Operations::List
include Invoiced::Operations::Update

OBJECT_NAME = 'payment_method'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/pdf_template.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class PdfTemplate < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'pdf_template'
end
end
7 changes: 7 additions & 0 deletions lib/invoiced/report.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Invoiced
class Report < Object
include Invoiced::Operations::Create

OBJECT_NAME = 'report'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/role.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class Role < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'role'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/sign_up_page.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class SignUpPage < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'sign_up_page'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/sms_template.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class SmsTemplate < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'sms_template'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/tax_rule.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class TaxRule < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'tax_rule'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/theme.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class Theme < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'theme'
end
end
10 changes: 10 additions & 0 deletions lib/invoiced/webhook.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Invoiced
class Webhook < Object
include Invoiced::Operations::List
include Invoiced::Operations::Create
include Invoiced::Operations::Update
include Invoiced::Operations::Delete

OBJECT_NAME = 'webhook'
end
end
17 changes: 17 additions & 0 deletions test/invoiced/custom_field_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require File.expand_path('../../test_helper', __FILE__)

module Invoiced
class CustomFieldTest < Test::Unit::TestCase
include Invoiced::Operations::EndpointTest
include Invoiced::Operations::CreateTest
include Invoiced::Operations::RetrieveTest
include Invoiced::Operations::UpdateTest
include Invoiced::Operations::DeleteTest
include Invoiced::Operations::ListTest

setup do
@objectClass = CustomField
@endpoint = '/custom_fields'
end
end
end
17 changes: 17 additions & 0 deletions test/invoiced/customer_chasing_cadence_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require File.expand_path('../../test_helper', __FILE__)

module Invoiced
class CustomerChasingCadenceTest < Test::Unit::TestCase
include Invoiced::Operations::EndpointTest
include Invoiced::Operations::CreateTest
include Invoiced::Operations::RetrieveTest
include Invoiced::Operations::UpdateTest
include Invoiced::Operations::DeleteTest
include Invoiced::Operations::ListTest

setup do
@objectClass = CustomerChasingCadence
@endpoint = '/customer_chasing_cadences'
end
end
end
17 changes: 17 additions & 0 deletions test/invoiced/email_template_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require File.expand_path('../../test_helper', __FILE__)

module Invoiced
class EmailTemplateTest < Test::Unit::TestCase
include Invoiced::Operations::EndpointTest
include Invoiced::Operations::CreateTest
include Invoiced::Operations::RetrieveTest
include Invoiced::Operations::UpdateTest
include Invoiced::Operations::DeleteTest
include Invoiced::Operations::ListTest

setup do
@objectClass = EmailTemplate
@endpoint = '/email_templates'
end
end
end
Loading

0 comments on commit 7374914

Please sign in to comment.