Class: ResinIO::Application
- Inherits:
-
Object
- Object
- ResinIO::Application
- Defined in:
- lib/resinio/application.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#commit ⇒ Object
readonly
Returns the value of attribute commit.
-
#device_type ⇒ Object
readonly
Returns the value of attribute device_type.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Application
constructor
A new instance of Application.
Constructor Details
#initialize(attributes) ⇒ Application
Returns a new instance of Application.
8 9 10 11 12 13 |
# 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 |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
7 8 9 |
# File 'lib/resinio/application.rb', line 7 def app_name @app_name end |
#commit ⇒ Object (readonly)
Returns the value of attribute commit.
7 8 9 |
# File 'lib/resinio/application.rb', line 7 def commit @commit end |
#device_type ⇒ Object (readonly)
Returns the value of attribute device_type.
7 8 9 |
# File 'lib/resinio/application.rb', line 7 def device_type @device_type end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/resinio/application.rb', line 7 def id @id end |
Class Method Details
.all ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# 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) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# 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 |