Class: Build47

Inherits:
Object
  • Object
show all
Defined in:
lib/build_47.rb

Overview

Do the work of uploading to to the App47 server using API V1

Class Method Summary collapse

Class Method Details

.api_v1_upload(options) ⇒ Object

Perform the upload to the server



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/build_47.rb', line 11

def self.api_v1_upload(options)
  app_id = options.delete(:app_id)
  token = options.delete(:token)
  load_file(options)

  RestClient::Request.execute(method: :post,
                              url: "https://cirrus.app47.com/api/apps/#{app_id}/builds",
                              payload: {
                                multipart: true,
                                build: options
                              },
                              headers: { accept: 'application/json', 'X-Token': token },
                              raw_response: true) do |response|
    puts "response code: #{response.code}"
  end
end

.load_file(options) ⇒ Object

Load file for processing, making sure it exists



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/build_47.rb', line 31

def self.load_file(options)
  file_path = options.delete(:path)
  raise "File not found: #{file_path}" unless File.exist?(file_path)

  options[:build_upload] = File.new(file_path, 'rb')
  extension = file_path.split('.').last
  options[:platform] = case extension
                       when 'ipa'
                         'iOS'
                       when 'apk'
                         'Android'
                       else
                         'Windows'
                       end
  options
end