fastlane-plugin-appscert 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6ba0d2a6dcb15ac98b613d9dceef4b3efdf962a4306c961fe351b977d42949b
4
- data.tar.gz: 11dc2aa82f684f6683788812aa50707a18d52113c00ef60acf060062f55adb29
3
+ metadata.gz: 5dc2f61b4be1a02f45077e71647c771f8912a05198b95ad57ac6329e49d58be0
4
+ data.tar.gz: 56c4e7cb1e9c994dd56b4ec75a5b1d080d949c5f1c762715b6d33163df073438
5
5
  SHA512:
6
- metadata.gz: 0a076e34f12001f542fb153201ee902bcf0a59a0422198a124d620918c6c3e221731a68a89bf9d687e27db4e394679f26badbd4f350f3c141cfa2221a2cbb176
7
- data.tar.gz: 17a2e7cdaa7376e705bc78b546b97c13ce9eda405e1b2b096ef04481106fe26ace10305072ec731ea375a180964a11782b413ef85872a2062c0b30d2bf39cf10
6
+ metadata.gz: 6ba2aa1624d8ae63fc12fbbfc7870c1b0494c8c6780c309a1d89c0547252c9079ea3891f61ddae3e3af19619ff893bb542f652603e757bc3997ced7bd4cf07ae
7
+ data.tar.gz: 98f64d4d58ed7ce3ad79aeb2e604d5fe58e377948206ee040b4e47763d6390de03b54425eba9c012e1829b3be7e696947d83b4e22179cf0c9b5c5ab4cb8eb8ed
@@ -4,36 +4,45 @@ require 'json'
4
4
  module Fastlane
5
5
  module Helper
6
6
  class AppscertHelper
7
- BASE_URL = 'https://appscert.com/api'
7
+ BASE_URL = 'https://appscert.com'
8
8
 
9
9
  def self.api_client(api_key, base_url: nil)
10
10
  url = base_url || ENV['APPSCERT_API_URL'] || BASE_URL
11
11
  Faraday.new(url: url) do |f|
12
12
  f.request :retry, max: 2
13
- f.headers['Authorization'] = "Bearer #{api_key}"
13
+ f.headers['X-API-Key'] = api_key
14
14
  f.headers['Content-Type'] = 'application/json'
15
15
  f.headers['User-Agent'] = 'fastlane-plugin-appscert/1.0.0'
16
16
  f.adapter Faraday.default_adapter
17
17
  end
18
18
  end
19
19
 
20
- def self.fetch_certificates(api_key, base_url: nil)
20
+ # Returns array of certificates
21
+ def self.fetch_certificates(api_key, base_url: nil, bundle_id: nil, type: nil)
21
22
  client = api_client(api_key, base_url: base_url)
22
- response = client.get('/certificates')
23
- raise "AppsCert API error: #{response.status}" unless response.status == 200
24
- JSON.parse(response.body)
23
+ params = {}
24
+ params[:bundle_id] = bundle_id if bundle_id
25
+ params[:type] = type if type
26
+ response = client.get('/api/ci', params)
27
+ raise "AppsCert API error #{response.status}: #{response.body}" unless response.status == 200
28
+ data = JSON.parse(response.body)
29
+ data.is_a?(Array) ? data : (data['certificates'] || [])
25
30
  end
26
31
 
27
- def self.fetch_profiles(api_key, base_url: nil)
32
+ # Returns array of provisioning profiles
33
+ def self.fetch_profiles(api_key, base_url: nil, bundle_id: nil)
28
34
  client = api_client(api_key, base_url: base_url)
29
- response = client.get('/profiles')
30
- raise "AppsCert API error: #{response.status}" unless response.status == 200
31
- JSON.parse(response.body)
35
+ params = { resource: 'profiles' }
36
+ params[:bundle_id] = bundle_id if bundle_id
37
+ response = client.get('/api/ci', params)
38
+ raise "AppsCert API error #{response.status}: #{response.body}" unless response.status == 200
39
+ data = JSON.parse(response.body)
40
+ data.is_a?(Array) ? data : (data['profiles'] || data['certificates'] || [])
32
41
  end
33
42
 
34
43
  def self.download_certificate(api_key, cert_id, output_path, base_url: nil)
35
44
  client = api_client(api_key, base_url: base_url)
36
- response = client.get("/certificates/#{cert_id}/download")
45
+ response = client.post('/api/ci', JSON.generate({ action: 'download', type: 'certificate', id: cert_id }))
37
46
  raise "Download failed: #{response.status}" unless response.status == 200
38
47
  File.write(output_path, response.body)
39
48
  output_path
@@ -41,7 +50,7 @@ module Fastlane
41
50
 
42
51
  def self.download_profile(api_key, profile_id, output_path, base_url: nil)
43
52
  client = api_client(api_key, base_url: base_url)
44
- response = client.get("/profiles/#{profile_id}/download")
53
+ response = client.post('/api/ci', JSON.generate({ action: 'download', type: 'profile', id: profile_id }))
45
54
  raise "Download failed: #{response.status}" unless response.status == 200
46
55
  File.write(output_path, response.body)
47
56
  output_path
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-appscert
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AppsCert