class Obniz::Client

Constants

URI

Public Class Methods

new(obniz_id:, access_token: nil) click to toggle source
# File lib/obniz/client.rb, line 5
def initialize(obniz_id:, access_token: nil)
  @uri = "#{URI}/#{obniz_id}/api/1"
  @client = HTTPClient.new
  @access_token = access_token
end

Public Instance Methods

post(params) click to toggle source
# File lib/obniz/client.rb, line 11
def post(params)
  headers = { 'Content-Type' => 'application/json' }
  headers['authorization'] = "Bearer #{@access_token}" unless @access_token.nil?
  # @client.debug_dev=STDOUT
  @client.post(@uri, body: params.to_json, header: headers)
end