Class: DeployGate::Client
- Inherits:
-
Object
- Object
- DeployGate::Client
- Defined in:
- lib/deploygate/deploygate_client.rb
Constant Summary collapse
- BASE_URL =
'https://deploygate.com/api'
Instance Method Summary collapse
-
#initialize(user, token) ⇒ Client
constructor
A new instance of Client.
- #upload(file, filename, message = nil, distribution_name = nil) ⇒ Object
Constructor Details
#initialize(user, token) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/deploygate/deploygate_client.rb', line 9 def initialize(user, token) @user = user @token = token end |
Instance Method Details
#upload(file, filename, message = nil, distribution_name = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/deploygate/deploygate_client.rb', line 14 def upload(file, filename, = nil, distribution_name = nil) data = [ ['file', file, { filename: filename }], ['token', @token], ] if data << ['message', ] end if distribution_name data << ['distribution_name', distribution_name] end uri = URI.parse(BASE_URL + "/users/#{@user}/apps") res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http| req = Net::HTTP::Post.new(uri) req.set_form(data, 'multipart/form-data') http.request(req) end ::DeployGate::Response.new(res) end |