Class: EShipper::OrderSearchRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/eshipper/requests/order_search_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Request

#build, #client, #send_now

Constructor Details

#initialize(fromDate: Date.today - 90, toDate: Date.today, carrierId: nil, statusId: nil, startOrderId: nil, endOrderId: nil, carrierTrackingNumber: nil, referenceValue: nil) ⇒ OrderSearchRequest

Returns a new instance of OrderSearchRequest.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/eshipper/requests/order_search_request.rb', line 14

def initialize(
  fromDate: Date.today - 90, # [Required]
  toDate: Date.today, # [Required]
  carrierId: nil, # [Optional]
  statusId: nil, # [Optional]
  startOrderId: nil, # [Optional]
  endOrderId: nil, # [Optional]
  carrierTrackingNumber: nil, # [Optional]
  referenceValue: nil # [Optional]
)
  throw("Order date range should be within 3 month.") if fromDate + 90 > toDate

  @fromDate = fromDate
  @toDate = toDate
  @carrierId = carrierId
  @statusId = statusId
  @startOrderId = startOrderId
  @endOrderId = endOrderId
  @carrierTrackingNumber = carrierTrackingNumber
  @referenceValue = referenceValue
  super()
end

Instance Attribute Details

#carrierIdObject (readonly)

Returns the value of attribute carrierId.



7
8
9
# File 'lib/eshipper/requests/order_search_request.rb', line 7

def carrierId
  @carrierId
end

#carrierTrackingNumberObject (readonly)

Returns the value of attribute carrierTrackingNumber.



11
12
13
# File 'lib/eshipper/requests/order_search_request.rb', line 11

def carrierTrackingNumber
  @carrierTrackingNumber
end

#endOrderIdObject (readonly)

Returns the value of attribute endOrderId.



10
11
12
# File 'lib/eshipper/requests/order_search_request.rb', line 10

def endOrderId
  @endOrderId
end

#fromDateObject (readonly)

Returns the value of attribute fromDate.



5
6
7
# File 'lib/eshipper/requests/order_search_request.rb', line 5

def fromDate
  @fromDate
end

#referenceValueObject (readonly)

Returns the value of attribute referenceValue.



12
13
14
# File 'lib/eshipper/requests/order_search_request.rb', line 12

def referenceValue
  @referenceValue
end

#startOrderIdObject (readonly)

Returns the value of attribute startOrderId.



9
10
11
# File 'lib/eshipper/requests/order_search_request.rb', line 9

def startOrderId
  @startOrderId
end

#statusIdObject (readonly)

Returns the value of attribute statusId.



8
9
10
# File 'lib/eshipper/requests/order_search_request.rb', line 8

def statusId
  @statusId
end

#toDateObject (readonly)

Returns the value of attribute toDate.



6
7
8
# File 'lib/eshipper/requests/order_search_request.rb', line 6

def toDate
  @toDate
end

Instance Method Details

#order_propertiesObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/eshipper/requests/order_search_request.rb', line 37

def order_properties
  {
    fromDate: fromDate,
    toDate: toDate,
    carrierId: carrierId,
    statusId: statusId,
    startOrderId: startOrderId,
    endOrderId: endOrderId,
    carrierTrackingNumber: carrierTrackingNumber,
    referenceValue: referenceValue,
  }.compact
end

#request_bodyObject



50
51
52
53
54
55
56
57
58
# File 'lib/eshipper/requests/order_search_request.rb', line 50

def request_body
  builder = build do |xml|
    xml.OrderSearchRequest do
      xml.Order(order_properties)
    end
  end

  builder.to_xml
end