class ChargeBee::Result

Public Class Methods

new(response) click to toggle source
# File lib/chargebee/result.rb, line 4
def initialize(response)
  @response = response
end

Public Instance Methods

addon() click to toggle source
# File lib/chargebee/result.rb, line 161
def addon() 
    addon = get(:addon, Addon,
    {:tiers => Addon::Tier});
    return addon;
end
address() click to toggle source
# File lib/chargebee/result.rb, line 183
def address() 
    address = get(:address, Address);
    return address;
end
advance_invoice_schedule() click to toggle source
# File lib/chargebee/result.rb, line 19
def advance_invoice_schedule() 
    advance_invoice_schedule = get(:advance_invoice_schedule, AdvanceInvoiceSchedule,
    {:fixed_interval_schedule => AdvanceInvoiceSchedule::FixedIntervalSchedule, :specific_dates_schedule => AdvanceInvoiceSchedule::SpecificDatesSchedule});
    return advance_invoice_schedule;
end
advance_invoice_schedules() click to toggle source
# File lib/chargebee/result.rb, line 283
def advance_invoice_schedules()
    advance_invoice_schedules = get_list(:advance_invoice_schedules, AdvanceInvoiceSchedule,
    {:fixed_interval_schedule => AdvanceInvoiceSchedule::FixedIntervalSchedule, :specific_dates_schedule => AdvanceInvoiceSchedule::SpecificDatesSchedule});
    return advance_invoice_schedules;
end
attached_item() click to toggle source
# File lib/chargebee/result.rb, line 259
def attached_item() 
    attached_item = get(:attached_item, AttachedItem);
    return attached_item;
end
card() click to toggle source
# File lib/chargebee/result.rb, line 62
def card() 
    card = get(:card, Card);
    return card;
end
comment() click to toggle source
# File lib/chargebee/result.rb, line 199
def comment() 
    comment = get(:comment, Comment);
    return comment;
end
contact() click to toggle source
# File lib/chargebee/result.rb, line 36
def contact() 
    contact = get(:contact, Contact);
    return contact;
end
contract_term() click to toggle source
# File lib/chargebee/result.rb, line 14
def contract_term() 
    contract_term = get(:contract_term, ContractTerm);
    return contract_term;
end
coupon() click to toggle source
# File lib/chargebee/result.rb, line 167
def coupon() 
    coupon = get(:coupon, Coupon,
    {:item_constraints => Coupon::ItemConstraint, :item_constraint_criteria => Coupon::ItemConstraintCriteria});
    return coupon;
end
coupon_code() click to toggle source
# File lib/chargebee/result.rb, line 178
def coupon_code() 
    coupon_code = get(:coupon_code, CouponCode);
    return coupon_code;
end
coupon_set() click to toggle source
# File lib/chargebee/result.rb, line 173
def coupon_set() 
    coupon_set = get(:coupon_set, CouponSet);
    return coupon_set;
end
credit_note() click to toggle source
# File lib/chargebee/result.rb, line 78
def credit_note() 
    credit_note = get(:credit_note, CreditNote,
    {:line_items => CreditNote::LineItem, :discounts => CreditNote::Discount, :line_item_discounts => CreditNote::LineItemDiscount, :line_item_tiers => CreditNote::LineItemTier, :taxes => CreditNote::Tax, :line_item_taxes => CreditNote::LineItemTax, :linked_refunds => CreditNote::LinkedRefund, :allocations => CreditNote::Allocation});
    return credit_note;
end
credit_notes() click to toggle source
# File lib/chargebee/result.rb, line 277
def credit_notes()
    credit_notes = get_list(:credit_notes, CreditNote,
    {:line_items => CreditNote::LineItem, :discounts => CreditNote::Discount, :line_item_discounts => CreditNote::LineItemDiscount, :line_item_tiers => CreditNote::LineItemTier, :taxes => CreditNote::Tax, :line_item_taxes => CreditNote::LineItemTax, :linked_refunds => CreditNote::LinkedRefund, :allocations => CreditNote::Allocation});
    return credit_notes;
end
customer() click to toggle source
# File lib/chargebee/result.rb, line 25
def customer() 
    customer = get(:customer, Customer,
    {:billing_address => Customer::BillingAddress, :referral_urls => Customer::ReferralUrl, :contacts => Customer::Contact, :payment_method => Customer::PaymentMethod, :balances => Customer::Balance, :relationship => Customer::Relationship, :parent_account_access => Customer::ParentAccountAccess, :child_account_access => Customer::ChildAccountAccess});
    return customer;
end
differential_price() click to toggle source
# File lib/chargebee/result.rb, line 264
def differential_price() 
    differential_price = get(:differential_price, DifferentialPrice,
    {:tiers => DifferentialPrice::Tier, :parent_periods => DifferentialPrice::ParentPeriod});
    return differential_price;
end
differential_prices() click to toggle source
# File lib/chargebee/result.rb, line 301
def differential_prices()
    differential_prices = get_list(:differential_prices, DifferentialPrice,
    {:tiers => DifferentialPrice::Tier, :parent_periods => DifferentialPrice::ParentPeriod});
    return differential_prices;
end
download() click to toggle source
# File lib/chargebee/result.rb, line 204
def download() 
    download = get(:download, Download);
    return download;
end
estimate() click to toggle source
# File lib/chargebee/result.rb, line 113
def estimate() 
    estimate = get(:estimate, Estimate, {},
    {:subscription_estimate => SubscriptionEstimate, :invoice_estimate => InvoiceEstimate, :invoice_estimates => InvoiceEstimate, :next_invoice_estimate => InvoiceEstimate, :credit_note_estimates => CreditNoteEstimate, :unbilled_charge_estimates => UnbilledCharge});
    estimate.init_dependant(@response[:estimate], :subscription_estimate,
    {:shipping_address => SubscriptionEstimate::ShippingAddress, :contract_term => SubscriptionEstimate::ContractTerm});
    estimate.init_dependant(@response[:estimate], :invoice_estimate,
    {:line_items => InvoiceEstimate::LineItem, :discounts => InvoiceEstimate::Discount, :taxes => InvoiceEstimate::Tax, :line_item_taxes => InvoiceEstimate::LineItemTax, :line_item_tiers => InvoiceEstimate::LineItemTier, :line_item_discounts => InvoiceEstimate::LineItemDiscount});
    estimate.init_dependant(@response[:estimate], :next_invoice_estimate,
    {:line_items => InvoiceEstimate::LineItem, :discounts => InvoiceEstimate::Discount, :taxes => InvoiceEstimate::Tax, :line_item_taxes => InvoiceEstimate::LineItemTax, :line_item_tiers => InvoiceEstimate::LineItemTier, :line_item_discounts => InvoiceEstimate::LineItemDiscount});
    estimate.init_dependant_list(@response[:estimate], :invoice_estimates,
    {:line_items => InvoiceEstimate::LineItem, :discounts => InvoiceEstimate::Discount, :taxes => InvoiceEstimate::Tax, :line_item_taxes => InvoiceEstimate::LineItemTax, :line_item_tiers => InvoiceEstimate::LineItemTier, :line_item_discounts => InvoiceEstimate::LineItemDiscount});
    estimate.init_dependant_list(@response[:estimate], :credit_note_estimates,
    {:line_items => CreditNoteEstimate::LineItem, :discounts => CreditNoteEstimate::Discount, :taxes => CreditNoteEstimate::Tax, :line_item_taxes => CreditNoteEstimate::LineItemTax, :line_item_discounts => CreditNoteEstimate::LineItemDiscount, :line_item_tiers => CreditNoteEstimate::LineItemTier});
    estimate.init_dependant_list(@response[:estimate], :unbilled_charge_estimates,
    {:tiers => UnbilledCharge::Tier});
    return estimate;
end
event() click to toggle source
# File lib/chargebee/result.rb, line 193
def event() 
    event = get(:event, Event,
    {:webhooks => Event::Webhook});
    return event;
end
export() click to toggle source
# File lib/chargebee/result.rb, line 230
def export() 
    export = get(:export, Export,
    {:download => Export::Download});
    return export;
end
gift() click to toggle source
# File lib/chargebee/result.rb, line 96
def gift() 
    gift = get(:gift, Gift,
    {:gifter => Gift::Gifter, :gift_receiver => Gift::GiftReceiver, :gift_timelines => Gift::GiftTimeline});
    return gift;
end
hierarchies() click to toggle source
# File lib/chargebee/result.rb, line 289
def hierarchies()
    hierarchies = get_list(:hierarchies, Hierarchy,
    {});
    return hierarchies;
end
hierarchy() click to toggle source
# File lib/chargebee/result.rb, line 31
def hierarchy() 
    hierarchy = get(:hierarchy, Hierarchy);
    return hierarchy;
end
hosted_page() click to toggle source
# File lib/chargebee/result.rb, line 108
def hosted_page() 
    hosted_page = get(:hosted_page, HostedPage);
    return hosted_page;
end
invoice() click to toggle source
# File lib/chargebee/result.rb, line 72
def invoice() 
    invoice = get(:invoice, Invoice,
    {:line_items => Invoice::LineItem, :discounts => Invoice::Discount, :line_item_discounts => Invoice::LineItemDiscount, :taxes => Invoice::Tax, :line_item_taxes => Invoice::LineItemTax, :line_item_tiers => Invoice::LineItemTier, :linked_payments => Invoice::LinkedPayment, :dunning_attempts => Invoice::DunningAttempt, :applied_credits => Invoice::AppliedCredit, :adjustment_credit_notes => Invoice::AdjustmentCreditNote, :issued_credit_notes => Invoice::IssuedCreditNote, :linked_orders => Invoice::LinkedOrder, :notes => Invoice::Note, :shipping_address => Invoice::ShippingAddress, :billing_address => Invoice::BillingAddress});
    return invoice;
end
invoices() click to toggle source
# File lib/chargebee/result.rb, line 295
def invoices()
    invoices = get_list(:invoices, Invoice,
    {:line_items => Invoice::LineItem, :discounts => Invoice::Discount, :line_item_discounts => Invoice::LineItemDiscount, :taxes => Invoice::Tax, :line_item_taxes => Invoice::LineItemTax, :line_item_tiers => Invoice::LineItemTier, :linked_payments => Invoice::LinkedPayment, :dunning_attempts => Invoice::DunningAttempt, :applied_credits => Invoice::AppliedCredit, :adjustment_credit_notes => Invoice::AdjustmentCreditNote, :issued_credit_notes => Invoice::IssuedCreditNote, :linked_orders => Invoice::LinkedOrder, :notes => Invoice::Note, :shipping_address => Invoice::ShippingAddress, :billing_address => Invoice::BillingAddress});
    return invoices;
end
item() click to toggle source
# File lib/chargebee/result.rb, line 247
def item() 
    item = get(:item, Item,
    {:applicable_items => Item::ApplicableItem});
    return item;
end
item_family() click to toggle source
# File lib/chargebee/result.rb, line 242
def item_family() 
    item_family = get(:item_family, ItemFamily);
    return item_family;
end
item_price() click to toggle source
# File lib/chargebee/result.rb, line 253
def item_price() 
    item_price = get(:item_price, ItemPrice,
    {:tiers => ItemPrice::Tier, :tax_detail => ItemPrice::TaxDetail, :accounting_detail => ItemPrice::AccountingDetail});
    return item_price;
end
order() click to toggle source
# File lib/chargebee/result.rb, line 90
def order() 
    order = get(:order, Order,
    {:order_line_items => Order::OrderLineItem, :shipping_address => Order::ShippingAddress, :billing_address => Order::BillingAddress, :line_item_taxes => Order::LineItemTax, :line_item_discounts => Order::LineItemDiscount, :linked_credit_notes => Order::LinkedCreditNote, :resent_orders => Order::ResentOrder});
    return order;
end
payment_intent() click to toggle source
# File lib/chargebee/result.rb, line 236
def payment_intent() 
    payment_intent = get(:payment_intent, PaymentIntent,
    {:payment_attempt => PaymentIntent::PaymentAttempt});
    return payment_intent;
end
payment_source() click to toggle source
# File lib/chargebee/result.rb, line 46
def payment_source() 
    payment_source = get(:payment_source, PaymentSource,
    {:card => PaymentSource::Card, :bank_account => PaymentSource::BankAccount, :amazon_payment => PaymentSource::AmazonPayment, :paypal => PaymentSource::Paypal});
    return payment_source;
end
plan() click to toggle source
# File lib/chargebee/result.rb, line 155
def plan() 
    plan = get(:plan, Plan,
    {:tiers => Plan::Tier, :applicable_addons => Plan::ApplicableAddon, :attached_addons => Plan::AttachedAddon, :event_based_addons => Plan::EventBasedAddon});
    return plan;
end
portal_session() click to toggle source
# File lib/chargebee/result.rb, line 209
def portal_session() 
    portal_session = get(:portal_session, PortalSession,
    {:linked_customers => PortalSession::LinkedCustomer});
    return portal_session;
end
promotional_credit() click to toggle source
# File lib/chargebee/result.rb, line 67
def promotional_credit() 
    promotional_credit = get(:promotional_credit, PromotionalCredit);
    return promotional_credit;
end
quote() click to toggle source
# File lib/chargebee/result.rb, line 131
def quote() 
    quote = get(:quote, Quote,
    {:line_items => Quote::LineItem, :discounts => Quote::Discount, :line_item_discounts => Quote::LineItemDiscount, :taxes => Quote::Tax, :line_item_taxes => Quote::LineItemTax, :line_item_tiers => Quote::LineItemTier, :shipping_address => Quote::ShippingAddress, :billing_address => Quote::BillingAddress});
    return quote;
end
quote_line_group() click to toggle source
# File lib/chargebee/result.rb, line 149
def quote_line_group() 
    quote_line_group = get(:quote_line_group, QuoteLineGroup,
    {:line_items => QuoteLineGroup::LineItem, :discounts => QuoteLineGroup::Discount, :line_item_discounts => QuoteLineGroup::LineItemDiscount, :taxes => QuoteLineGroup::Tax, :line_item_taxes => QuoteLineGroup::LineItemTax});
    return quote_line_group;
end
quoted_charge() click to toggle source
# File lib/chargebee/result.rb, line 143
def quoted_charge() 
    quoted_charge = get(:quoted_charge, QuotedCharge,
    {:charges => QuotedCharge::Charge, :addons => QuotedCharge::Addon, :invoice_items => QuotedCharge::InvoiceItem, :item_tiers => QuotedCharge::ItemTier, :coupons => QuotedCharge::Coupon});
    return quoted_charge;
end
quoted_subscription() click to toggle source
# File lib/chargebee/result.rb, line 137
def quoted_subscription() 
    quoted_subscription = get(:quoted_subscription, QuotedSubscription,
    {:addons => QuotedSubscription::Addon, :event_based_addons => QuotedSubscription::EventBasedAddon, :coupons => QuotedSubscription::Coupon, :subscription_items => QuotedSubscription::SubscriptionItem, :item_tiers => QuotedSubscription::ItemTier, :quoted_contract_term => QuotedSubscription::QuotedContractTerm});
    return quoted_subscription;
end
resource_migration() click to toggle source
# File lib/chargebee/result.rb, line 220
def resource_migration() 
    resource_migration = get(:resource_migration, ResourceMigration);
    return resource_migration;
end
site_migration_detail() click to toggle source
# File lib/chargebee/result.rb, line 215
def site_migration_detail() 
    site_migration_detail = get(:site_migration_detail, SiteMigrationDetail);
    return site_migration_detail;
end
subscription() click to toggle source
# File lib/chargebee/result.rb, line 8
def subscription() 
    subscription = get(:subscription, Subscription,
    {:subscription_items => Subscription::SubscriptionItem, :item_tiers => Subscription::ItemTier, :charged_items => Subscription::ChargedItem, :addons => Subscription::Addon, :event_based_addons => Subscription::EventBasedAddon, :charged_event_based_addons => Subscription::ChargedEventBasedAddon, :coupons => Subscription::Coupon, :shipping_address => Subscription::ShippingAddress, :referral_info => Subscription::ReferralInfo, :contract_term => Subscription::ContractTerm});
    return subscription;
end
third_party_payment_method() click to toggle source
# File lib/chargebee/result.rb, line 52
def third_party_payment_method() 
    third_party_payment_method = get(:third_party_payment_method, ThirdPartyPaymentMethod);
    return third_party_payment_method;
end
time_machine() click to toggle source
# File lib/chargebee/result.rb, line 225
def time_machine() 
    time_machine = get(:time_machine, TimeMachine);
    return time_machine;
end
to_s(*args) click to toggle source
# File lib/chargebee/result.rb, line 308
def to_s(*args)
    JSON.pretty_generate(@response)
end
token() click to toggle source
# File lib/chargebee/result.rb, line 41
def token() 
    token = get(:token, Token);
    return token;
end
transaction() click to toggle source
# File lib/chargebee/result.rb, line 102
def transaction() 
    transaction = get(:transaction, Transaction,
    {:linked_invoices => Transaction::LinkedInvoice, :linked_credit_notes => Transaction::LinkedCreditNote, :linked_refunds => Transaction::LinkedRefund, :linked_payments => Transaction::LinkedPayment});
    return transaction;
end
unbilled_charge() click to toggle source
# File lib/chargebee/result.rb, line 84
def unbilled_charge() 
    unbilled_charge = get(:unbilled_charge, UnbilledCharge,
    {:tiers => UnbilledCharge::Tier});
    return unbilled_charge;
end
unbilled_charges() click to toggle source
# File lib/chargebee/result.rb, line 271
def unbilled_charges()
    unbilled_charges = get_list(:unbilled_charges, UnbilledCharge,
    {:tiers => UnbilledCharge::Tier});
    return unbilled_charges;
end
usage() click to toggle source
# File lib/chargebee/result.rb, line 188
def usage() 
    usage = get(:usage, Usage);
    return usage;
end
virtual_bank_account() click to toggle source
# File lib/chargebee/result.rb, line 57
def virtual_bank_account() 
    virtual_bank_account = get(:virtual_bank_account, VirtualBankAccount);
    return virtual_bank_account;
end

Private Instance Methods

get(type, klass, sub_types = {}, dependant_types = {}) click to toggle source
# File lib/chargebee/result.rb, line 332
def get(type, klass, sub_types = {}, dependant_types = {})
  return klass.construct(@response[type], sub_types, dependant_types)
end
get_list(type, klass, sub_types = {}, dependant_types = {}, dependant_sub_types = {}) click to toggle source
# File lib/chargebee/result.rb, line 313
def get_list(type, klass, sub_types = {}, dependant_types = {}, dependant_sub_types = {})
  if(@response[type] == nil)
    return nil
  end
  set_val = Array.new
  @response[type].each do |obj|
    case obj
    when Hash
      model = klass.construct(obj, sub_types, dependant_types)
      dependant_sub_types.each do |k,v|
            model.init_dependant(obj, k, v);
      end
      set_val.push(model)
    end
  end
  return instance_variable_set("@#{type}", set_val)
end