Class: Spaceship::Tunes::IAPFamilies

Inherits:
TunesBase show all
Defined in:
spaceship/lib/spaceship/tunes/iap_families.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#client, #raw_data

Instance Method Summary collapse

Methods inherited from TunesBase

client

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

#applicationSpaceship::Tunes::Application

Returns A reference to the application.

Returns:



7
8
9
# File 'spaceship/lib/spaceship/tunes/iap_families.rb', line 7

def application
  @application
end

Instance Method Details

#allObject

returns a list of all available subscription groups/families of the current In-App-Purchase



44
45
46
47
48
49
50
51
52
53
54
# File 'spaceship/lib/spaceship/tunes/iap_families.rb', line 44

def all
  r = client.iap_families(app_id: self.application.apple_id)
  return_families = []
  r.each do |family|
    attrs = family
    attrs[:application] = self.application
    loaded_family = Tunes::IAPFamilyList.factory(attrs)
    return_families << loaded_family
  end
  return_families
end

#create!(name: nil, product_id: nil, reference_name: nil, versions: {}) ⇒ Object

Create a new Purchase Family a freshly created family has to have at least one product. the product will be created, and versions/pricing_intervals and so on should be set by subsequent edit. }

Examples:

versions: {
'de-DE': {
  subscription_name: "Subname German",
  name: 'App Name German',
},
'da': {
  subscription_name: "Subname DA",
  name: 'App Name DA',
}

Parameters:

  • name (String) (defaults to: nil)

    Familyname

  • product_id (String) (defaults to: nil)

    New Product’s id

  • reference_name (String) (defaults to: nil)

    Reference name of the new product

  • versions (Hash) (defaults to: {})

    Localized Family names



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'spaceship/lib/spaceship/tunes/iap_families.rb', line 29

def create!(name: nil, product_id: nil, reference_name: nil, versions: {})
  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 }
              }
    }
  end
  client.create_iap_family(app_id: self.application.apple_id, name: name, product_id: product_id, reference_name: reference_name, versions: versions_array)
end

#find(family_id) ⇒ Object

find a specific family

Parameters:

  • family_id (String)

    Family Id



58
59
60
61
62
63
64
65
# File 'spaceship/lib/spaceship/tunes/iap_families.rb', line 58

def find(family_id)
  all.each do |family|
    if family.family_id == family_id
      return family
    end
  end
  return nil
end