Sha256: 89627ea1d5c61cbeae9b692c6bb41bae34248d716f739450255fba6a5305a2a1

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

module Trustvox
  # Responsible to api calls about store
  class Store < Base

    # Call create store api
    # @param store_data
    def create(store_data)
      auth_by_platform_token!
      response = self.class.post('/stores', { body: store_data.to_json })
      data = JSON.parse(response.body) rescue nil

      {
        status: response.code,
        data: data,
      }
    end

    # Call order api
    # @param order_data
    def push_order(order_data)
      body = Utils.build_push_order_data(order_data)
      auth_by_store_token!
      response = self.class.post("/stores/#{Config.store_id}/orders", { body: body.to_json })
      data = JSON.parse(response.body) rescue nil

      { status: response.code, data: data }
    end

    # Call store lookup api
    # @param url
    def load_store(url)
      auth_by_platform_token!
      response = self.class.get("/stores", { query: { url: url} })
      data = JSON.parse(response.body) rescue nil

      {
        status: response.code,
        data: data,
      }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trustvox-0.4.0 lib/trustvox/store.rb
trustvox-0.3.0 lib/trustvox/store.rb
trustvox-0.2.0 lib/trustvox/store.rb
trustvox-0.1.0 lib/trustvox/store.rb