Class: Cashbox::Subscription

Inherits:
Model
  • Object
show all
Includes:
Concern::Objectable, Rest::Cancel, Rest::Disentitle, Rest::ReadWrite
Defined in:
lib/cashbox/model/subscription.rb

Constant Summary collapse

IN_RETRY =
"In Retry".freeze
FAILED_TO_COLLECT =
"Failed To Collect".freeze
GRACE_PERIOD =
"Grace Period".freeze

Constants included from Rest::ReadWrite

Rest::ReadWrite::DEFAULT_LIMIT

Instance Method Summary collapse

Methods included from Concern::Objectable

included

Instance Method Details

#failed_to_collect?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/cashbox/model/subscription.rb', line 42

def failed_to_collect?
  billing_state == FAILED_TO_COLLECT
end

#grace_period?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/cashbox/model/subscription.rb', line 46

def grace_period?
  billing_state == GRACE_PERIOD
end

#in_retry?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/cashbox/model/subscription.rb', line 38

def in_retry?
  billing_state == IN_RETRY
end

#modify_subscription_items(subscription_items, bill_prorated, effective_date = 'today') ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cashbox/model/subscription.rb', line 50

def modify_subscription_items(subscription_items, bill_prorated, effective_date='today')
  request = Cashbox::Request.new(:post, route(vid),
      {
          query: {
              effective_date: effective_date,
              bill_prorated_period: bill_prorated
          },
          body: {
              id: id,
              items: subscription_items
          }.to_json
      })
  self.class.cast(self, request.response)
end