Class: Spaceship::Portal::Key
Constant Summary
collapse
- APNS_ID =
data model for managing JWT tokens or “Keys” as the ADP refers to them
'U27F4V844T'
- DEVICE_CHECK_ID =
'DQ8HTZ7739'
- MUSIC_KIT_ID =
'6A7HVUVQ3M'
Instance Attribute Summary collapse
Attributes inherited from Base
#client, #raw_data
Class Method Summary
collapse
Instance Method Summary
collapse
client
Methods inherited from Base
attr_accessor, attr_mapping, attributes, #attributes, factory, #initialize, #inspect, mapping_module, method_missing, set_client, #setup, #to_s
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
13
14
15
|
# File 'spaceship/lib/spaceship/portal/key.rb', line 13
def id
@id
end
|
#name ⇒ Object
Returns the value of attribute name.
14
15
16
|
# File 'spaceship/lib/spaceship/portal/key.rb', line 14
def name
@name
end
|
Class Method Details
.all ⇒ Object
24
25
26
27
28
29
|
# File 'spaceship/lib/spaceship/portal/key.rb', line 24
def self.all
keys = client.list_keys
keys.map do |key|
new(key)
end
end
|
.create(name: nil, apns: nil, device_check: nil, music_id: nil) ⇒ Object
Creates a new JWT / Key for making requests to services.
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'spaceship/lib/spaceship/portal/key.rb', line 43
def self.create(name: nil, apns: nil, device_check: nil, music_id: nil)
service_config = {}
if apns
service_config[APNS_ID] = {
scope: 'team',
environment: 'all',
identifiers: {}
}
end
if device_check
service_config[DEVICE_CHECK_ID] = {
identifiers: {}
}
end
if music_id
service_config[MUSIC_KIT_ID] = {
identifiers: {
music: [music_id]
}
}
end
key = client.create_key!(name: name, service_configs: service_config)
new(key)
end
|
.find(id) ⇒ Object
31
32
33
34
|
# File 'spaceship/lib/spaceship/portal/key.rb', line 31
def self.find(id)
key = client.get_key(id: id)
new(key)
end
|
Instance Method Details
#download ⇒ Object
76
77
78
|
# File 'spaceship/lib/spaceship/portal/key.rb', line 76
def download
client.download_key(id: id)
end
|
#has_apns? ⇒ Boolean
91
92
93
|
# File 'spaceship/lib/spaceship/portal/key.rb', line 91
def has_apns?
has_service?(APNS_ID)
end
|
#has_device_check? ⇒ Boolean
99
100
101
|
# File 'spaceship/lib/spaceship/portal/key.rb', line 99
def has_device_check?
has_service?(DEVICE_CHECK_ID)
end
|
#has_music_kit? ⇒ Boolean
95
96
97
|
# File 'spaceship/lib/spaceship/portal/key.rb', line 95
def has_music_kit?
has_service?(MUSIC_KIT_ID)
end
|
#reload ⇒ Object
103
104
105
|
# File 'spaceship/lib/spaceship/portal/key.rb', line 103
def reload
self.raw_data = self.class.find(id).raw_data
end
|
#revoke! ⇒ Object
72
73
74
|
# File 'spaceship/lib/spaceship/portal/key.rb', line 72
def revoke!
client.revoke_key!(id: id)
end
|
#service_configs_for(service_id) ⇒ Object
85
86
87
88
89
|
# File 'spaceship/lib/spaceship/portal/key.rb', line 85
def service_configs_for(service_id)
if (service = find_service(service_id))
service['configurations']
end
end
|
#services ⇒ Object
80
81
82
83
|
# File 'spaceship/lib/spaceship/portal/key.rb', line 80
def services
raw_data['services'] || reload
super
end
|