Class: Manabu::ContactTypes
- Inherits:
-
Object
- Object
- Manabu::ContactTypes
- Defined in:
- lib/manabu/contact_types.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(client) ⇒ ContactTypes
constructor
A new instance of ContactTypes.
- #register(name) ⇒ Object
Constructor Details
#initialize(client) ⇒ ContactTypes
Returns a new instance of ContactTypes.
5 6 7 8 |
# File 'lib/manabu/contact_types.rb', line 5 def initialize(client) @client = client @contact_types = {} end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
3 4 5 |
# File 'lib/manabu/contact_types.rb', line 3 def client @client end |
Instance Method Details
#all ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/manabu/contact_types.rb', line 17 def all return @contact_types unless @contact_types.empty? response = @client.get("/contact_types") @contact_types = response[:contact_types].each_with_object({}) do |type, obj| obj[type[:name]] = type[:id] end end |
#register(name) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/manabu/contact_types.rb', line 10 def register(name) response = @client.post("/contact_types", name: name) response[:id] rescue nil end |