Class: Apps::Adapters::Gmail::Markup::ParcelDelivery

Inherits:
BaseContext show all
Defined in:
lib/apps/adapters/gmail/markup/parcel_delivery.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseContext

#to_script

Methods inherited from Base

#initialize, #to_json, #type

Constructor Details

This class inherits a constructor from Apps::Adapters::Gmail::Markup::Base

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



10
11
12
# File 'lib/apps/adapters/gmail/markup/parcel_delivery.rb', line 10

def action
  @action
end

#carrier_nameObject

Returns the value of attribute carrier_name.



11
12
13
# File 'lib/apps/adapters/gmail/markup/parcel_delivery.rb', line 11

def carrier_name
  @carrier_name
end

#delivery_addressObject

Returns the value of attribute delivery_address.



11
12
13
# File 'lib/apps/adapters/gmail/markup/parcel_delivery.rb', line 11

def delivery_address
  @delivery_address
end

#expected_arrival_untilObject

Returns the value of attribute expected_arrival_until.



11
12
13
# File 'lib/apps/adapters/gmail/markup/parcel_delivery.rb', line 11

def expected_arrival_until
  @expected_arrival_until
end

#merchant_nameObject

Returns the value of attribute merchant_name.



12
13
14
# File 'lib/apps/adapters/gmail/markup/parcel_delivery.rb', line 12

def merchant_name
  @merchant_name
end

#order_numberObject

Returns the value of attribute order_number.



12
13
14
# File 'lib/apps/adapters/gmail/markup/parcel_delivery.rb', line 12

def order_number
  @order_number
end

#product_nameObject

Returns the value of attribute product_name.



12
13
14
# File 'lib/apps/adapters/gmail/markup/parcel_delivery.rb', line 12

def product_name
  @product_name
end

#tracking_urlObject

Returns the value of attribute tracking_url.



13
14
15
# File 'lib/apps/adapters/gmail/markup/parcel_delivery.rb', line 13

def tracking_url
  @tracking_url
end

Instance Method Details

#as_jsonObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/apps/adapters/gmail/markup/parcel_delivery.rb', line 15

def as_json
  prune super.merge(
    "deliveryAddress" => delivery_address&.as_json,
    "expectedArrivalUntil" => expected_arrival_until,
    "carrier" => {
      "@type" => "Organization",
      "name" => carrier_name
    },
    "itemShipped" => {
      "@type" => "Product",
      "name" => product_name
    },
    "partOfOrder" => {
      "@type" => "Order",
      "orderNumber" => order_number,
      "merchant" => {
        "@type" => "Organization",
        "name" => merchant_name
      }
    },
    "trackingUrl" => tracking_url,
    "potentialAction" => action&.as_json
  )
end

#build_delivery_address(**attrs) ⇒ Object



40
41
42
# File 'lib/apps/adapters/gmail/markup/parcel_delivery.rb', line 40

def build_delivery_address(**attrs)
  self.delivery_address = PostalAddress.new(**attrs)
end