Class: Myrr::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/myrr/card.rb

Overview

Virtual card issued to a wallet.

Card numbers, expiry, and CVC are returned ONLY at creation time. Subsequent lookups return last4 only.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Card

Returns a new instance of Card.

Parameters:

  • attrs (Hash)

    Card attributes from the API



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/myrr/card.rb', line 13

def initialize(attrs)
  @id = attrs["id"]
  @wallet_id = attrs["wallet_id"]
  @last4 = attrs["last4"]
  @brand = attrs["brand"] || "visa"
  @status = attrs["status"]
  @controls = attrs["controls"]
  @number = attrs["number"]
  @expiry = attrs["expiry"]
  @cvc = attrs["cvc"]
  @created_at = attrs["created_at"]
  @updated_at = attrs["updated_at"]
end

Instance Attribute Details

#brandObject (readonly)

Returns the value of attribute brand.



9
10
11
# File 'lib/myrr/card.rb', line 9

def brand
  @brand
end

#controlsObject (readonly)

Returns the value of attribute controls.



9
10
11
# File 'lib/myrr/card.rb', line 9

def controls
  @controls
end

#created_atObject (readonly)

Returns the value of attribute created_at.



9
10
11
# File 'lib/myrr/card.rb', line 9

def created_at
  @created_at
end

#cvcObject (readonly)

Returns the value of attribute cvc.



9
10
11
# File 'lib/myrr/card.rb', line 9

def cvc
  @cvc
end

#expiryObject (readonly)

Returns the value of attribute expiry.



9
10
11
# File 'lib/myrr/card.rb', line 9

def expiry
  @expiry
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/myrr/card.rb', line 9

def id
  @id
end

#last4Object (readonly)

Returns the value of attribute last4.



9
10
11
# File 'lib/myrr/card.rb', line 9

def last4
  @last4
end

#numberObject (readonly)

Returns the value of attribute number.



9
10
11
# File 'lib/myrr/card.rb', line 9

def number
  @number
end

#statusObject (readonly)

Returns the value of attribute status.



9
10
11
# File 'lib/myrr/card.rb', line 9

def status
  @status
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



9
10
11
# File 'lib/myrr/card.rb', line 9

def updated_at
  @updated_at
end

#wallet_idObject (readonly)

Returns the value of attribute wallet_id.



9
10
11
# File 'lib/myrr/card.rb', line 9

def wallet_id
  @wallet_id
end

Instance Method Details

#cancel!Object

Permanently cancel this card.



42
43
44
45
46
# File 'lib/myrr/card.rb', line 42

def cancel!
  resp = client.delete("/v1/wallets/#{wallet_id}/cards/#{id}")
  @status = resp["status"]
  self
end

#freeze!Object

Freeze this card (no new authorizations).



28
29
30
31
32
# File 'lib/myrr/card.rb', line 28

def freeze!
  resp = client.post("/v1/wallets/#{wallet_id}/cards/#{id}/freeze", {})
  @status = resp["status"]
  self
end

#unfreeze!Object

Unfreeze this card.



35
36
37
38
39
# File 'lib/myrr/card.rb', line 35

def unfreeze!
  resp = client.post("/v1/wallets/#{wallet_id}/cards/#{id}/unfreeze", {})
  @status = resp["status"]
  self
end