class ResinIO::Application
Attributes
app_name[R]
commit[R]
device_type[R]
id[R]
Public Class Methods
all()
click to toggle source
# File lib/resinio/application.rb, line 30 def self.all conn = Faraday.new(url: "#{API_URL}/application") do |faraday| faraday.adapter Faraday.default_adapter # make requests with Net::HTTP faraday.headers['Content-Type'] = 'application/json' # form-encode POST params faraday.headers['Authorization'] = "Bearer #{ENV['RESIN_API_KEY']}" # form-encode POST params end response = conn.get parsed_response = JSON.parse(response.body) applications = parsed_response['d'] result = applications.map { |application| new(application) } # byebug end
find(id)
click to toggle source
# File lib/resinio/application.rb, line 15 def self.find(id) conn = Faraday.new(url: "#{API_URL}/application(#{id})") do |faraday| faraday.adapter Faraday.default_adapter # make requests with Net::HTTP faraday.headers['Content-Type'] = 'application/json' # form-encode POST params faraday.headers['Authorization'] = "Bearer #{ENV['RESIN_API_KEY']}" # form-encode POST params # faraday.request :url_encoded # form-encode POST params # faraday.response :logger # log requests to $stdout end response = conn.get parsed_response = JSON.parse(response.body) attributes = parsed_response['d'][0] # byebug new(attributes) end
new(attributes)
click to toggle source
# File lib/resinio/application.rb, line 8 def initialize(attributes) @id = attributes['id'] @app_name = attributes['app_name'] @commit = attributes['commit'] @device_type = attributes['device_type'] end