Class: Spaceship::Tunes::IAP
- Defined in:
- spaceship/lib/spaceship/tunes/iap.rb
Instance Attribute Summary collapse
-
#application ⇒ Spaceship::Tunes::Application
A reference to the application.
Attributes inherited from Base
Instance Method Summary collapse
-
#all(include_deleted: false) ⇒ Object
return all available In-App-Purchase’s of current app this is not paged inside iTC-API so if you have a lot if IAP’s (2k+) it might take some time to load, same as it takes when you load the list via iTunes Connect.
-
#create!(type: "consumable", versions: nil, reference_name: nil, product_id: nil, cleared_for_sale: true, review_notes: nil, review_screenshot: nil, pricing_intervals: nil, family_id: nil, subscription_free_trial: nil, subscription_duration: nil) ⇒ Object
Creates a new In-App-Purchese on iTunes Connect if the In-App-Purchase already exists an exception is raised.
-
#families ⇒ Spaceship::Tunes::IAPFamilies
A reference to the familie list.
-
#find(product_id) ⇒ Object
find a specific product.
- #transform_pricing_intervals(pricing_intervals) ⇒ Object
Methods inherited from TunesBase
Methods inherited from Base
attr_accessor, attr_mapping, attributes, #attributes, factory, #initialize, #inspect, mapping_module, method_missing, set_client, #setup, #to_s
Constructor Details
This class inherits a constructor from Spaceship::Base
Instance Attribute Details
#application ⇒ Spaceship::Tunes::Application
Returns A reference to the application.
16 17 18 |
# File 'spaceship/lib/spaceship/tunes/iap.rb', line 16 def application @application end |
Instance Method Details
#all(include_deleted: false) ⇒ Object
return all available In-App-Purchase’s of current app this is not paged inside iTC-API so if you have a lot if IAP’s (2k+) it might take some time to load, same as it takes when you load the list via iTunes Connect
122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'spaceship/lib/spaceship/tunes/iap.rb', line 122 def all(include_deleted: false) r = client.iaps(app_id: self.application.apple_id) return_iaps = [] r.each do |product| attrs = product attrs[:application] = self.application loaded_iap = Tunes::IAPList.factory(attrs) next if loaded_iap.status == "deleted" && !include_deleted return_iaps << loaded_iap end return_iaps end |
#create!(type: "consumable", versions: nil, reference_name: nil, product_id: nil, cleared_for_sale: true, review_notes: nil, review_screenshot: nil, pricing_intervals: nil, family_id: nil, subscription_free_trial: nil, subscription_duration: nil) ⇒ Object
Creates a new In-App-Purchese on iTunes Connect if the In-App-Purchase already exists an exception is raised. Spaceship::TunesClient::ITunesConnectError @example: {
'de-DE': {
name: "Name shown in AppStore",
description: "Description of the In app Purchase"
}
} @example:
[
{
country: "WW",
begin_date: nil,
end_date: nil,
tier: 1
}
]
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'spaceship/lib/spaceship/tunes/iap.rb', line 55 def create!(type: "consumable", versions: nil, reference_name: nil, product_id: nil, cleared_for_sale: true, review_notes: nil, review_screenshot: nil, pricing_intervals: nil, family_id: nil, subscription_free_trial: nil, subscription_duration: nil) client.create_iap!(app_id: self.application.apple_id, type: type, versions: versions, reference_name: reference_name, product_id: product_id, cleared_for_sale: cleared_for_sale, review_notes: review_notes, review_screenshot: review_screenshot, pricing_intervals: pricing_intervals, family_id: family_id, subscription_duration: subscription_duration, subscription_free_trial: subscription_free_trial) # Update pricing for a recurring subscription. if type == Spaceship::Tunes::IAPType::RECURRING && pricing_intervals # There are cases where the product that was just created is not immediately found, # and in order to update its pricing the purchase_id is needed. Therefore polling is done # for 4 times until it is found. If it's not found after 4 tries, a PotentialServerError # exception is raised. product = find_product_with_retries(product_id, 4) transformed_pricing_intervals = transform_pricing_intervals(pricing_intervals) client.update_recurring_iap_pricing!(app_id: self.application.apple_id, purchase_id: product.purchase_id, pricing_intervals: transformed_pricing_intervals) end end |
#families ⇒ Spaceship::Tunes::IAPFamilies
Returns A reference to the familie list.
19 20 21 22 23 |
# File 'spaceship/lib/spaceship/tunes/iap.rb', line 19 def families attrs = {} attrs[:application] = self.application Tunes::IAPFamilies.new(attrs) end |
#find(product_id) ⇒ Object
find a specific product
110 111 112 113 114 115 116 117 |
# File 'spaceship/lib/spaceship/tunes/iap.rb', line 110 def find(product_id) all.each do |product| if product.product_id == product_id return product end end return nil end |
#transform_pricing_intervals(pricing_intervals) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'spaceship/lib/spaceship/tunes/iap.rb', line 94 def transform_pricing_intervals(pricing_intervals) pricing_intervals.map do |interval| { "value" => { "tierStem" => interval[:tier], "priceTierEffectiveDate" => interval[:begin_date], "priceTierEndDate" => interval[:end_date], "country" => interval[:country] || "WW", "grandfathered" => interval[:grandfathered] } } end end |