Class: Spaceship::Tunes::Member
- 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
-
#email_address ⇒ Object
Returns the value of attribute email_address.
-
#firstname ⇒ Object
Returns the value of attribute firstname.
-
#lastname ⇒ Object
Returns the value of attribute lastname.
-
#not_accepted_invitation ⇒ Object
Returns the value of attribute not_accepted_invitation.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
-
#username ⇒ Object
Returns the value of attribute username.
Attributes inherited from Base
Instance Method Summary collapse
- #admin? ⇒ Boolean
- #app_manager? ⇒ Boolean
- #delete! ⇒ Object
- #has_all_apps ⇒ Object
- #preferred_currency ⇒ Object
- #resend_invitation ⇒ Object
- #roles ⇒ Object
- #selected_apps ⇒ Object
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
#email_address ⇒ Object
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 |
#firstname ⇒ Object
Returns the value of attribute firstname.
8 9 10 |
# File 'spaceship/lib/spaceship/tunes/member.rb', line 8 def firstname @firstname end |
#lastname ⇒ Object
Returns the value of attribute lastname.
9 10 11 |
# File 'spaceship/lib/spaceship/tunes/member.rb', line 9 def lastname @lastname end |
#not_accepted_invitation ⇒ Object
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_id ⇒ Object
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 |
#username ⇒ Object
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
39 40 41 |
# File 'spaceship/lib/spaceship/tunes/member.rb', line 39 def admin? roles.include?(ROLES[:admin]) end |
#app_manager? ⇒ Boolean
43 44 45 |
# File 'spaceship/lib/spaceship/tunes/member.rb', line 43 def app_manager? roles.include?(ROLES[:app_manager]) end |
#delete! ⇒ Object
75 76 77 |
# File 'spaceship/lib/spaceship/tunes/member.rb', line 75 def delete! client.delete_member!(self.user_id, self.email_address) end |
#has_all_apps ⇒ Object
71 72 73 |
# File 'spaceship/lib/spaceship/tunes/member.rb', line 71 def has_all_apps selected_apps.length == 0 end |
#preferred_currency ⇒ Object
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_invitation ⇒ Object
79 80 81 |
# File 'spaceship/lib/spaceship/tunes/member.rb', line 79 def resend_invitation client.reinvite_member(self.email_address) end |
#roles ⇒ Object
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_apps ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'spaceship/lib/spaceship/tunes/member.rb', line 57 def selected_apps parsed_apps = [] all_apps = Application.all raw_data["userSoftwares"]["value"]["grantedSoftwareAdamIds"].each do |app_id| parsed_apps << all_apps.select { |app| app.apple_id == app_id } end return parsed_apps.flatten end |