Class: Unit::Card::ReplaceCardRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/card/replace_card_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(card_id, shipping_address = nil) ⇒ ReplaceCardRequest

Returns a new instance of ReplaceCardRequest.

Parameters:

  • card_id (String)
  • shipping_address (Address) (defaults to: nil)
    • optional



12
13
14
15
# File 'lib/unit/models/card/replace_card_request.rb', line 12

def initialize(card_id, shipping_address = nil)
  @card_id = card_id
  @shipping_address = shipping_address
end

Instance Attribute Details

#card_idObject (readonly)

Returns the value of attribute card_id.



8
9
10
# File 'lib/unit/models/card/replace_card_request.rb', line 8

def card_id
  @card_id
end

#shipping_addressObject (readonly)

Returns the value of attribute shipping_address.



8
9
10
# File 'lib/unit/models/card/replace_card_request.rb', line 8

def shipping_address
  @shipping_address
end

Instance Method Details

#to_json_apiObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/unit/models/card/replace_card_request.rb', line 17

def to_json_api
  payload = {
    "data": {
      "type": "replaceCard",
      "attributes": {
        "shippingAddress": shipping_address&.represent
      }
    }
  }
  payload[:data][:attributes].compact!
  payload.to_json
end