Class: Starship::Client
- Inherits:
-
Object
- Object
- Starship::Client
- Defined in:
- lib/starship.rb
Constant Summary collapse
- DEV_SERVICES_V1 =
"https://developer.apple.com/services-account/v1"
- DEV_SERVICES_QH65B2 =
"https://developer.apple.com/services-account/QH65B2"
Class Method Summary collapse
- .auth_helper ⇒ Object
- .create_app_group(app_group, team_id) ⇒ Object
- .create_bundle(bundle_identifier, team_id, capabilities) ⇒ Object
- .create_provisioning_profile(team_id, bundle_id, bundle_identifier, certificate_id, devices) ⇒ Object
- .get_app_groups(team_id) ⇒ Object
- .get_bundle_ids(team_id) ⇒ Object
- .get_bundle_info(bundle_id, team_id) ⇒ Object
- .get_devices(team_id) ⇒ Object
- .get_profiles(team_id) ⇒ Object
- .get_provisioning_profile(profile_id, team_id) ⇒ Object
- .patch_bundle(bundleInfo, team_id, capabilities) ⇒ Object
- .regen_provisioning_profile(profile, team_id, devices) ⇒ Object
Class Method Details
.auth_helper ⇒ Object
20 21 22 |
# File 'lib/starship.rb', line 20 def auth_helper @auth_helper ||= AuthHelper.new end |
.create_app_group(app_group, team_id) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/starship.rb', line 122 def create_app_group(app_group, team_id) response = authenticated_request( DEV_SERVICES_QH65B2 + "/account/ios/identifiers/addApplicationGroup.action", method: :post, body: URI.encode_www_form( "name" => generate_name_for(app_group), "identifier" => app_group, "teamId" => team_id, ), headers: { "Content-Type" => "application/x-www-form-urlencoded" }, ) if response.status == 200 JSON.parse(response.body) else raise "Failed to create app group: #{response.status}" end end |
.create_bundle(bundle_identifier, team_id, capabilities) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/starship.rb', line 140 def create_bundle(bundle_identifier, team_id, capabilities) response = authenticated_request( DEV_SERVICES_V1 + "/bundleIds", method: :post, body: { data: { type: "bundleIds", attributes: { identifier: bundle_identifier, name: generate_name_for(bundle_identifier), seedId: team_id, teamId: team_id, }, relationships: { bundleIdCapabilities: { data: capabilities, }, }, }, }.to_json, headers: { "Content-Type" => "application/vnd.api+json", "X-HTTP-Method-Override" => nil, }, ) if response.status == 201 JSON.parse(response.body) else raise "Failed to create bundle: #{response.status}" end end |
.create_provisioning_profile(team_id, bundle_id, bundle_identifier, certificate_id, devices) ⇒ Object
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/starship.rb', line 208 def create_provisioning_profile(team_id, bundle_id, bundle_identifier, certificate_id, devices) response = authenticated_request( DEV_SERVICES_V1 + "/profiles", method: :post, body: { data: { type: "profiles", attributes: { name: generate_name_for(bundle_identifier), profileType: "IOS_APP_ADHOC", teamId: team_id, }, relationships: { bundleId: { data: { type: "bundleIds", id: bundle_id, }, }, certificates: { data: [{ type: "certificates", id: certificate_id, }], }, devices: { data: devices.map { |device| { type: "devices", id: device["id"] } }, }, }, }, }.to_json, headers: { "Content-Type" => "application/vnd.api+json", "X-HTTP-Method-Override" => nil, }, ) if response.status == 201 JSON.parse(response.body) else raise "Failed to create profile: #{response.status}" end end |
.get_app_groups(team_id) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/starship.rb', line 103 def get_app_groups(team_id) response = authenticated_request( DEV_SERVICES_QH65B2 + "/account/ios/identifiers/listApplicationGroups.action", method: :post, body: URI.encode_www_form( "teamId" => team_id, "pageSize" => 1000, "pageNumber" => 1, "sort" => "name%3Dasc", ), headers: { "Content-Type" => "application/x-www-form-urlencoded" }, ) if response.status == 200 JSON.parse(response.body)["applicationGroupList"] else raise "Failed to list bundle IDs: #{response.status}" end end |
.get_bundle_ids(team_id) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/starship.rb', line 24 def get_bundle_ids(team_id) response = authenticated_request( DEV_SERVICES_V1 + "/bundleIds", method: :post, body: { teamId: team_id, urlEncodedQueryParams: "limit=1000&sort=name&filter[platform]=IOS,MACOS" }.to_json, headers: { "Content-Type" => "application/vnd.api+json" }, ) if response.status == 200 JSON.parse(response.body)["data"] else raise "Failed to get bundle IDs: #{response.status}" end end |
.get_bundle_info(bundle_id, team_id) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/starship.rb', line 88 def get_bundle_info(bundle_id, team_id) response = authenticated_request( DEV_SERVICES_V1 + "/bundleIds/#{bundle_id}?include=bundleIdCapabilities,bundleIdCapabilities.capability,bundleIdCapabilities.appGroups", method: :post, body: { teamId: team_id }.to_json, headers: { "Content-Type" => "application/vnd.api+json" }, ) if response.status == 200 JSON.parse(response.body) else raise "Failed to get bundle info: #{response.status}" end end |
.get_devices(team_id) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/starship.rb', line 39 def get_devices(team_id) response = authenticated_request( DEV_SERVICES_V1 + "/devices", method: :post, body: { teamId: team_id, urlEncodedQueryParams: "limit=1000&sort=name" }.to_json, headers: { "Content-Type" => "application/vnd.api+json" }, ) if response.status == 200 JSON.parse(response.body)["data"] else raise "Failed to get devices: #{response.status}" end end |
.get_profiles(team_id) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/starship.rb', line 54 def get_profiles(team_id) response = authenticated_request( DEV_SERVICES_V1 + "/profiles", method: :post, body: { teamId: team_id, urlEncodedQueryParams: "limit=1000&sort=name" }.to_json, headers: { "Content-Type" => "application/vnd.api+json" }, ) if response.status == 200 JSON.parse(response.body)["data"] else raise "Failed to get profiles: #{response.status}" end end |
.get_provisioning_profile(profile_id, team_id) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/starship.rb', line 69 def get_provisioning_profile(profile_id, team_id) response = authenticated_request( DEV_SERVICES_QH65B2 + "/account/ios/profile/getProvisioningProfile.action", method: :post, body: URI.encode_www_form( "teamId" => team_id, "includeInactiveProfiles" => true, "provisioningProfileId" => profile_id, ), headers: { "Content-Type" => "application/x-www-form-urlencoded" }, ) if response.status == 200 JSON.parse(response.body) else raise "Failed to get profile: #{response.status}" end end |
.patch_bundle(bundleInfo, team_id, capabilities) ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/starship.rb', line 172 def patch_bundle(bundleInfo, team_id, capabilities) bundle_id = bundleInfo["data"]["id"] bundle_attributes = bundleInfo["data"]["attributes"] response = authenticated_request( DEV_SERVICES_V1 + "/bundleIds/#{bundle_id}", method: :patch, body: { data: { type: "bundleIds", id: bundle_id, attributes: { identifier: bundle_attributes["identifier"], permissions: { "edit": true, "delete": true }, seedId: bundle_attributes["seedId"], name: bundle_attributes["name"], wildcard: bundle_attributes["wildcard"], teamId: team_id, }, relationships: { bundleIdCapabilities: { data: capabilities, }, }, }, }.to_json, headers: { "Content-Type" => "application/vnd.api+json" }, ) if response.status == 200 JSON.parse(response.body) else raise "Failed to patch bundle capabilities: #{response.status}" end end |
.regen_provisioning_profile(profile, team_id, devices) ⇒ Object
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/starship.rb', line 251 def regen_provisioning_profile(profile, team_id, devices) response = authenticated_request( DEV_SERVICES_QH65B2 + "/account/ios/profile/regenProvisioningProfile.action", method: :post, body: URI.encode_www_form( "appIdId" => profile["provisioningProfile"]["appIdId"], "provisioningProfileId" => profile["provisioningProfile"]["provisioningProfileId"], "distributionType" => profile["provisioningProfile"]["distributionType"], # TODO: figure out how to get this from old profile "isOfflineProfile" => false, "provisioningProfileName" => profile["provisioningProfile"]["name"], "certificateIds" => profile["provisioningProfile"]["certificateIds"].join(","), "deviceIds" => devices, "teamId" => team_id, ), headers: { "Content-Type" => "application/x-www-form-urlencoded" }, ) if response.status == 200 JSON.parse(response.body) else raise "Failed to regenerate profile: #{response.status}" end end |