class Ernest::API
Attributes
data[R]
Public Class Methods
new(data)
click to toggle source
# File lib/ernest/api.rb, line 11 def initialize(data) @data = data end
with_data(data)
click to toggle source
# File lib/ernest/api.rb, line 7 def self.with_data(data) new(data) end
Public Instance Methods
post()
click to toggle source
# File lib/ernest/api.rb, line 15 def post HTTParty.post( ENV['API_ENDPOINT'], body: http_data, headers: { 'Authorization' => 'Token token="' + ENV['TOKEN'] + '"' } ) end
put(id)
click to toggle source
# File lib/ernest/api.rb, line 23 def put(id) HTTParty.put( ENV['API_ENDPOINT'] + "/#{id}", body: http_data, headers: { 'Authorization' => 'Token token="' + ENV['TOKEN'] + '"' } ) end
Private Instance Methods
http_data()
click to toggle source
# File lib/ernest/api.rb, line 35 def http_data { post: { body: data.output }.merge(data.metadata) } end