Class: DHLEcommerceAPI::Base

Inherits:
ActiveResource::Base
  • Object
show all
Defined in:
lib/dhl_ecommerce_api/resources/base.rb

Instance Method Summary collapse

Instance Method Details

#account_idsObject



12
13
14
15
16
17
# File 'lib/dhl_ecommerce_api/resources/base.rb', line 12

def 
  {
    "pickupAccountId": DHLEcommerceAPI.config.,
    "soldToAccountId": DHLEcommerceAPI.config.,
  }
end

#attributes_with_account_idsObject



8
9
10
# File 'lib/dhl_ecommerce_api/resources/base.rb', line 8

def 
  .merge(attributes)
end

#custom_key_format(key) ⇒ Object

custom keys that arent following lowerCamel convention



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/dhl_ecommerce_api/resources/base.rb', line 24

def custom_key_format(key)
  case key.to_s
  when "shipment_id"
    "shipmentID"
  when "total_weight_uom"
    "totalWeightUOM"
  when "dimension_uom"
    "dimensionUOM"
  when "order_url"
    "orderURL"
  when "location_id"
    "locationID"
  when "piece_id"
    "pieceID"
  when "weight_uom"
    "weightUOM"
  when "marketplace_url"
    "marketplaceURL"
  when "handover_id"
    "handoverID"
  when "email_id"
    "emailID"
  when "e_pod_required"
    "ePODRequired"
  else
    key.to_s.camelize(:lower)
  end
end

#handle_errors(code, error_messages) ⇒ Object



19
20
21
# File 'lib/dhl_ecommerce_api/resources/base.rb', line 19

def handle_errors(code, error_messages)
  errors.add(:base, "#{code} - #{error_messages.join(", ")}")
end