Sha256: d08471f07caeb7e66161eff973e85f8968de823efd05f1fbafde48bd2e70c693
Contents?: true
Size: 1011 Bytes
Versions: 1
Compression:
Stored size: 1011 Bytes
Contents
module Moip2 class OrderApi attr_reader :client def initialize(client) @client = client end def base_path "/v2/orders" end def create(order) Resource::Order.new client, client.post(base_path, order) end def show(id) Resource::Order.new client, client.get("#{base_path}/#{id}") end def find_all(limit: nil, offset: nil, filters: nil) encoded_filters = Moip2::Util::FiltersEncoder.encode(filters) # `URI.encode...` will accept nil params, but they will pollute the URI params = { limit: limit, offset: offset, filters: encoded_filters, }.reject { |_, value| value.nil? } query_string = URI.encode_www_form(params) path = "#{base_path}?#{query_string}" response = client.get(path) # We need to transform raw JSON in Order objects response.orders.collect! { |order| Resource::Order.new client, order } Resource::Order.new client, response end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
moip2-1.0.0 | lib/moip2/order_api.rb |