Class: Spaceship::Portal::Merchant

Inherits:
Spaceship::PortalBase show all
Defined in:
spaceship/lib/spaceship/portal/merchant.rb

Overview

Represents a Merchant ID from the Developer Portal

Instance Attribute Summary collapse

Attributes inherited from Base

#client, #raw_data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Spaceship::PortalBase

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

#bundle_idString

Returns The bundle_id (merchant identifier) of merchant id.

Examples:

"merchant.com.krausefx.app.production"

Returns:

  • (String)

    The bundle_id (merchant identifier) of merchant id



30
31
32
# File 'spaceship/lib/spaceship/portal/merchant.rb', line 30

def bundle_id
  @bundle_id
end

#merchant_idString

Returns The identifier of this merchant, provided by the Dev Portal.

Examples:

"LM1UX73BAC"

Returns:

  • (String)

    The identifier of this merchant, provided by the Dev Portal



10
11
12
# File 'spaceship/lib/spaceship/portal/merchant.rb', line 10

def merchant_id
  @merchant_id
end

#nameString

Returns The name you provided for this merchant.

Examples:

"Spaceship Production"

Returns:

  • (String)

    The name you provided for this merchant



15
16
17
# File 'spaceship/lib/spaceship/portal/merchant.rb', line 15

def name
  @name
end

#platformString

Returns the supported platform of this merchant.

Examples:

"ios"

Returns:

  • (String)

    the supported platform of this merchant



20
21
22
# File 'spaceship/lib/spaceship/portal/merchant.rb', line 20

def platform
  @platform
end

#prefixObject

Prefix provided by the Dev Portal

Examples:

"5A9972XTK2"


25
26
27
# File 'spaceship/lib/spaceship/portal/merchant.rb', line 25

def prefix
  @prefix
end

#statusString

Returns Status of the merchant.

Examples:

"current"

Returns:

  • (String)

    Status of the merchant



35
36
37
# File 'spaceship/lib/spaceship/portal/merchant.rb', line 35

def status
  @status
end

Class Method Details

.all(mac: false) ⇒ Array

Returns all merchants available for this account

Parameters:

  • mac (Bool) (defaults to: false)

    Fetches Mac merchant if true

Returns:

  • (Array)

    Returns all merchants available for this account



48
49
50
# File 'spaceship/lib/spaceship/portal/merchant.rb', line 48

def all(mac: false)
  client.merchants(mac: mac).map { |merchant| new(merchant) }
end

.create!(bundle_id: nil, name: nil, mac: false) ⇒ Merchant

Creates a new Merchant on the Apple Dev Portal

Parameters:

  • bundle_id (String) (defaults to: nil)

    the bundle id (merchant_identifier) of the merchant

  • name (String) (defaults to: nil)

    the name of the Merchant

  • mac (Bool) (defaults to: false)

    is this a Mac Merchant?

Returns:

  • (Merchant)

    The Merchant you just created



58
59
60
61
# File 'spaceship/lib/spaceship/portal/merchant.rb', line 58

def create!(bundle_id: nil, name: nil, mac: false)
  new_merchant = client.create_merchant!(name, bundle_id, mac: mac)
  new(new_merchant)
end

.find(bundle_id, mac: false) ⇒ Merchant

Find a specific Merchant ID based on the bundle_id

Parameters:

  • mac (Bool) (defaults to: false)

    Searches Mac merchants if true

Returns:

  • (Merchant)

    The Merchant you’re looking for. This is nil if the merchant can’t be found.



66
67
68
69
70
# File 'spaceship/lib/spaceship/portal/merchant.rb', line 66

def find(bundle_id, mac: false)
  all(mac: mac).find do |merchant|
    merchant.bundle_id == bundle_id
  end
end

Instance Method Details

#delete!Merchant

Delete this Merchant

Returns:

  • (Merchant)

    The merchant you just deleted



75
76
77
78
# File 'spaceship/lib/spaceship/portal/merchant.rb', line 75

def delete!
  client.delete_merchant!(merchant_id, mac: mac?)
  self
end

#mac?Bool

Returns Is this a Mac merchant?.

Returns:

  • (Bool)

    Is this a Mac merchant?



81
82
83
# File 'spaceship/lib/spaceship/portal/merchant.rb', line 81

def mac?
  platform == 'mac'
end