Class: Bluedart::Shipment

Inherits:
Base
  • Object
show all
Defined in:
lib/bluedart/shipment.rb

Instance Method Summary collapse

Constructor Details

#initialize(details) ⇒ Shipment

Returns a new instance of Shipment.



3
4
5
6
7
8
9
# File 'lib/bluedart/shipment.rb', line 3

def initialize(details)
  @shipper = shipper_hash(details[:shipper_details])
  @consignee = consignee_hash(details[:consignee_details])
  @services = services_hash(details[:services])
  @profile = profile_hash({api_type: 'S', version: '1.3'}, details[:creds])
  @mode = details[:mode]
end

Instance Method Details

#request_urlObject



11
12
13
14
15
16
17
# File 'lib/bluedart/shipment.rb', line 11

def request_url
  if @mode == 'prod'
    'https://netconnect.bluedart.com/ShippingAPI/WayBill/WayBillGeneration.svc'
  else
    'http://netconnect.bluedart.com/Demo/ShippingAPI/WayBill/WayBillGeneration.svc'
  end
end

#responseObject



19
20
21
22
23
24
25
26
# File 'lib/bluedart/shipment.rb', line 19

def response
  wsa = 'http://tempuri.org/IWayBillGeneration/GenerateWayBill'
  # TODO: ITS A HACK NEEDS TO BE REMOVED
  # TODO: NEED TO REWRITE TO USE NAMESPACES DEFINED IN NAMESPACES FUNCTION
  params = {'Request' => {'ns4:Consignee' => @consignee, 'ns4:Services' => @services, 'ns4:Shipper' => @shipper}}
  opts = {message: 'GenerateWayBill', wsa: wsa, params: params, extra: {'Profile' => @profile}, url: request_url}
  make_request(opts)
end