class AndroidInAppBilling::SubscriptionPurchase

Represents SubscriptionPurchase resource from android publisher v2 API @see developers.google.com/android-publisher/api-ref/purchases/subscriptions

Constants

Attributes
CANCEL_REASONS
PAYMENT_STATES

Public Class Methods

new(raw_subscription_purchase) click to toggle source

@param raw_subscription_purchase [Hash] @!attribute kind

@return [String]

@!attribute auto_renewing

@return [true,false]

@!attribute country_code

@return [String]

@!attribute price_amount_micros

@return [Integer]

@!attribute price_currency_code

@return [String]

@!attribute payment_state

@return [String,nil]

@!attribute expires_at

@return [DateTime]

@!attribute started_at

@return [DateTime]

@!attribute user_cancelled_at

@return [DateTime,nil]

@!attribute cancel_reason

@return [String,nil]

@!attribute developer_payload

@return [String,nil]
Calls superclass method
# File lib/android_in_app_billing/subscription_purchase.rb, line 49
def initialize(raw_subscription_purchase)
  super Attributes.new(*parse_raw(raw_subscription_purchase))
end

Private Instance Methods

parse_raw(raw) click to toggle source
# File lib/android_in_app_billing/subscription_purchase.rb, line 55
def parse_raw(raw) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
  [
    raw.fetch(:kind),
    raw.fetch(:auto_renewing),
    raw.fetch(:country_code),
    raw.fetch(:price_amount_micros).to_i,
    raw.fetch(:price_currency_code),
    PAYMENT_STATES[raw.fetch(:payment_state, nil)],
    millis_to_datetime(raw.fetch(:expiry_time_millis)),
    millis_to_datetime(raw.fetch(:start_time_millis)),
    millis_to_datetime(raw.fetch(:user_cancellation_time_millis, nil)),
    CANCEL_REASONS[raw.fetch(:cancel_reason, nil)],
    raw.fetch(:developer_payload, nil)
  ]
end