Module: Spaceship::Tunes::IAPType

Defined in:
spaceship/lib/spaceship/tunes/iap_type.rb

Overview

Constant Summary collapse

CONSUMABLE =
"consumable"
NON_CONSUMABLE =
"nonConsumable"
RECURRING =
"recurring"
NON_RENEW_SUBSCRIPTION =
"subscription"
READABLE_CONSUMABLE =

A product that is used once

"Consumable"
READABLE_NON_CONSUMABLE =

A product that is purchased once and does not expire or decrease with use.

"Non-Consumable"
READABLE_AUTO_RENEWABLE_SUBSCRIPTION =

A product that allows users to purchase dynamic content for a set period (auto-rene).

"Auto-Renewable Subscription"
READABLE_NON_RENEWING_SUBSCRIPTION =

A product that allows users to purchase a service with a limited duration.

"Non-Renewing Subscription"

Class Method Summary collapse

Class Method Details

.get_from_string(text) ⇒ Object

Get the iap type matching based on a string (given by App Store Connect)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'spaceship/lib/spaceship/tunes/iap_type.rb', line 25

def self.get_from_string(text)
  mapping = {
    'ITC.addons.type.consumable' => READABLE_CONSUMABLE,
    'ITC.addons.type.nonConsumable' => READABLE_NON_CONSUMABLE,
    'ITC.addons.type.recurring' => READABLE_AUTO_RENEWABLE_SUBSCRIPTION,
    'ITC.addons.type.subscription' => READABLE_NON_RENEWING_SUBSCRIPTION,
    'consumable' => READABLE_CONSUMABLE,
    'nonConsumable' => READABLE_NON_CONSUMABLE,
    'recurring' => READABLE_AUTO_RENEWABLE_SUBSCRIPTION,
    'subscription' => READABLE_NON_RENEWING_SUBSCRIPTION
  }

  mapping.each do |itc_type, readable_type|
    return readable_type if itc_type == text
  end

  return nil
end