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 App Store 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, subscription_price_target: nil) ⇒ Object
Creates a new In-App-Purchese on App Store 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.
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 App Store Connect
120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'spaceship/lib/spaceship/tunes/iap.rb', line 120 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, subscription_price_target: nil) ⇒ Object
Creates a new In-App-Purchese on App Store 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
}
]
price of all the countries to be roughly the same as the price calculated from the price tier and currency given as input. @example:
{
currency: "EUR",
tier: 2
}
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 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'spaceship/lib/spaceship/tunes/iap.rb', line 63 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, subscription_price_target: 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 || subscription_price_target) # 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 6 tries, a PotentialServerError # exception is raised. product = find_product_with_retries(product_id, 6) raw_pricing_intervals = client.transform_to_raw_pricing_intervals(application.apple_id, product.purchase_id, pricing_intervals, subscription_price_target) client.update_recurring_iap_pricing!(app_id: self.application.apple_id, purchase_id: product.purchase_id, pricing_intervals: raw_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
108 109 110 111 112 113 114 115 |
# File 'spaceship/lib/spaceship/tunes/iap.rb', line 108 def find(product_id) all.each do |product| if product.product_id == product_id return product end end return nil end |