Class: Spaceship::Tunes::IAPFamilyDetails
- Defined in:
- spaceship/lib/spaceship/tunes/iap_family_details.rb
Instance Attribute Summary collapse
-
#application ⇒ Spaceship::Tunes::Application
A reference to the application.
-
#family_details ⇒ Array
Of all in-app purchase family details.
-
#family_id ⇒ Intger
The family id.
-
#iap_count ⇒ Intger
Amount of linked in-app purchases of this family (read-only).
-
#linked_iaps ⇒ Array
All linked in-app purchases of this family.
-
#name ⇒ String
The family name.
Attributes inherited from Base
Instance Method Summary collapse
-
#save! ⇒ Object
modify existing family.
-
#versions ⇒ Hash
Localized names.
-
#versions=(value = {}) ⇒ Object
transforms user-set versions to iTC ones.
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.
7 8 9 |
# File 'spaceship/lib/spaceship/tunes/iap_family_details.rb', line 7 def application @application end |
#family_details ⇒ Array
Returns of all in-app purchase family details.
22 23 24 |
# File 'spaceship/lib/spaceship/tunes/iap_family_details.rb', line 22 def family_details @family_details end |
#family_id ⇒ Intger
Returns the family id.
13 14 15 |
# File 'spaceship/lib/spaceship/tunes/iap_family_details.rb', line 13 def family_id @family_id end |
#iap_count ⇒ Intger
Returns amount of linked in-app purchases of this family (read-only).
19 20 21 |
# File 'spaceship/lib/spaceship/tunes/iap_family_details.rb', line 19 def iap_count @iap_count end |
#linked_iaps ⇒ Array
Returns all linked in-app purchases of this family.
16 17 18 |
# File 'spaceship/lib/spaceship/tunes/iap_family_details.rb', line 16 def linked_iaps @linked_iaps end |
#name ⇒ String
Returns the family name.
10 11 12 |
# File 'spaceship/lib/spaceship/tunes/iap_family_details.rb', line 10 def name @name end |
Instance Method Details
#save! ⇒ Object
modify existing family
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'spaceship/lib/spaceship/tunes/iap_family_details.rb', line 70 def save! # Transform localization versions back to original format. versions_array = [] versions.each do |language_code, value| versions_array << { "value" => { "subscriptionName" => { "value" => value[:subscription_name] }, "name" => { "value" => value[:name] }, "localeCode" => { "value" => language_code.to_s }, "id" => value[:id] } } end raw_data.set(["details"], { "value" => versions_array }) client.update_iap_family!(app_id: application.apple_id, family_id: self.family_id, data: raw_data) end |
#versions ⇒ Hash
Returns localized names.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'spaceship/lib/spaceship/tunes/iap_family_details.rb', line 33 def versions parsed_versions = {} raw_versions = raw_data["details"]["value"] raw_versions.each do |version| language = version["value"]["localeCode"]["value"] parsed_versions[language.to_sym] = { subscription_name: version["value"]["subscriptionName"]["value"], name: version["value"]["name"]["value"], id: version["value"]["id"], status: version["value"]["status"] } end return parsed_versions end |
#versions=(value = {}) ⇒ Object
transforms user-set versions to iTC ones
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'spaceship/lib/spaceship/tunes/iap_family_details.rb', line 49 def versions=(value = {}) if value.kind_of?(Array) # input that comes from iTC api return end new_versions = [] value.each do |language, current_version| new_versions << { "value" => { "subscriptionName" => { "value" => current_version[:subscription_name] }, "name" => { "value" => current_version[:name] }, "localeCode" => { "value" => language }, "id" => current_version[:id] } } end raw_data.set(["details"], { "value" => new_versions }) end |