Sha256: 8d84415ce4606af132c566f5c6cb4250629597c18f8b2432cb91b6e0bceecbd7

Contents?: true

Size: 752 Bytes

Versions: 4

Compression:

Stored size: 752 Bytes

Contents

module Trustvox
  # Responsible to api calls about store
  class Utils
    DEFAULT_ORDER = {
      order_id: nil,
      delivery_date: nil,
      client: {},
      items: [],
      tags: []
    }

    DEFAULT_ORDER_ITEM = {
      id: nil,
      url: nil,
      name: nil,
      price: nil,
      photos_urls: [],
      tags: [],
      extra: {}
    }

    DEFAULT_CLIENT = {
      first_name: nil,
      last_name: nil,
      email: nil,
      tags: []
    }

    def self.build_push_order_data(order_data)
      body = DEFAULT_ORDER.merge(order_data)

      body[:items] = order_data[:items].map do |item|
        DEFAULT_ORDER_ITEM.merge(item)
      end

      body[:client] = DEFAULT_CLIENT .merge(order_data[:client])

      body
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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