Class: Spaceship::Tunes::Member

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

Constant Summary collapse

ROLES =
{
  admin: 'admin',
  app_manager: 'appmanager',
  sales: 'sales',
  developer: 'developer',
  marketing: 'marketing',
  reports: 'reports'
}

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

#email_addressObject

Returns the value of attribute email_address


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

def email_address
  @email_address
end

#firstnameObject

Returns the value of attribute firstname


8
9
10
# File 'spaceship/lib/spaceship/tunes/member.rb', line 8

def firstname
  @firstname
end

#lastnameObject

Returns the value of attribute lastname


9
10
11
# File 'spaceship/lib/spaceship/tunes/member.rb', line 9

def lastname
  @lastname
end

#not_accepted_invitationObject

Returns the value of attribute not_accepted_invitation


11
12
13
# File 'spaceship/lib/spaceship/tunes/member.rb', line 11

def not_accepted_invitation
  @not_accepted_invitation
end

#user_idObject

Returns the value of attribute user_id


12
13
14
# File 'spaceship/lib/spaceship/tunes/member.rb', line 12

def user_id
  @user_id
end

#usernameObject

Returns the value of attribute username


10
11
12
# File 'spaceship/lib/spaceship/tunes/member.rb', line 10

def username
  @username
end

Instance Method Details

#admin?Boolean

Returns:

  • (Boolean)

39
40
41
# File 'spaceship/lib/spaceship/tunes/member.rb', line 39

def admin?
  roles.include?(ROLES[:admin])
end

#app_manager?Boolean

Returns:

  • (Boolean)

43
44
45
# File 'spaceship/lib/spaceship/tunes/member.rb', line 43

def app_manager?
  roles.include?(ROLES[:app_manager])
end

#delete!Object


74
75
76
# File 'spaceship/lib/spaceship/tunes/member.rb', line 74

def delete!
  client.delete_member!(self.user_id, self.email_address)
end

#has_all_appsObject


70
71
72
# File 'spaceship/lib/spaceship/tunes/member.rb', line 70

def has_all_apps
  selected_apps.length == 0
end

#preferred_currencyObject


47
48
49
50
51
52
53
54
55
# File 'spaceship/lib/spaceship/tunes/member.rb', line 47

def preferred_currency
  currency_base = raw_data["preferredCurrency"]["value"]
  return {
    name:    currency_base["name"],
    code:    currency_base["currencyCode"],
    country: currency_base["countryName"],
    country_code: currency_base["countryCode"]
  }
end

#resend_invitationObject


78
79
80
# File 'spaceship/lib/spaceship/tunes/member.rb', line 78

def resend_invitation
  client.reinvite_member(self.email_address)
end

#rolesObject


31
32
33
34
35
36
37
# File 'spaceship/lib/spaceship/tunes/member.rb', line 31

def roles
  parsed_roles = []
  raw_data["roles"].each do |role|
    parsed_roles << role["value"]["name"]
  end
  return parsed_roles
end

#selected_appsObject


57
58
59
60
61
62
63
# File 'spaceship/lib/spaceship/tunes/member.rb', line 57

def selected_apps
  parsed_apps = []
  raw_data["userSoftwares"]["value"]["grantedSoftwareAdamIds"].each do |app_id|
    parsed_apps << Application.find(app_id)
  end
  return parsed_apps
end