class NftmakerApi::Client

Attributes

api_key[R]
configuration[R]
host[R]
last_response[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/nftmaker_api/client.rb, line 7
def initialize(options = {})
  @configuration = OpenStruct.new(
    NftmakerApi.configuration.to_h.merge(options)
  )

  @api_key = @configuration.api_key
  @host = @configuration.host
end

Public Instance Methods

get(endpoint) click to toggle source
# File lib/nftmaker_api/client.rb, line 36
def get(endpoint)
  @last_response = Response.new(http_client.get endpoint)
end
http_client() click to toggle source
# File lib/nftmaker_api/client.rb, line 48
def http_client
  @http_client ||= Faraday.new(url: host, headers: {'Content-Type' => 'application/json'}) do |f|
    f.adapter configuration.http_adapter
  end
end
nfts() click to toggle source
# File lib/nftmaker_api/client.rb, line 24
def nfts
  Nfts.new(self)
end
post(endpoint, body) click to toggle source
# File lib/nftmaker_api/client.rb, line 40
def post(endpoint, body)
  response = http_client.post(endpoint) do |req|
    req.body = Oj.dump(body)
  end

  @last_response = Response.new(response)
end
project(id) click to toggle source
# File lib/nftmaker_api/client.rb, line 20
def project(id)
  Project.new(self, id)
end
projects() click to toggle source
# File lib/nftmaker_api/client.rb, line 16
def projects
  Projects.new(self)
end
reservation(project_id:, address:) click to toggle source
# File lib/nftmaker_api/client.rb, line 32
def reservation(project_id:, address:)
  Reservation.new(self, project_id: project_id, address: address)
end
reservations(project_id:) click to toggle source
# File lib/nftmaker_api/client.rb, line 28
def reservations(project_id:)
  Reservations.new(self, project_id: project_id)
end