Class: Ernest::API
- Inherits:
-
Object
- Object
- Ernest::API
- Defined in:
- lib/ernest/api.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ API
constructor
A new instance of API.
- #post ⇒ Object
- #put(id) ⇒ Object
Constructor Details
#initialize(data) ⇒ API
Returns a new instance of API.
11 12 13 |
# File 'lib/ernest/api.rb', line 11 def initialize(data) @data = data end |
Class Method Details
.with_data(data) ⇒ Object
7 8 9 |
# File 'lib/ernest/api.rb', line 7 def self.with_data(data) new(data) end |
Instance Method Details
#post ⇒ Object
15 16 17 18 19 20 21 |
# 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) ⇒ Object
23 24 25 26 27 28 29 |
# 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 |