Class: BloomRemit2::Agent
- Inherits:
-
Object
- Object
- BloomRemit2::Agent
- Defined in:
- lib/bloom_remit2/agent.rb
Instance Attribute Summary collapse
-
#deleted ⇒ Object
readonly
Returns the value of attribute deleted.
-
#deleted_at ⇒ Object
readonly
Returns the value of attribute deleted_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.create(name) ⇒ Object
Create a new agent under this partner.
-
.delete(agent_id) ⇒ Object
Delete an agent belonging to this partner.
-
.list ⇒ Object
Show a list of agents belonging to this partner.
-
.retrieve(id) ⇒ Object
Show an agent belonging to this partner.
Instance Method Summary collapse
-
#initialize(id, name, deleted_at = nil, deleted: false) ⇒ Agent
constructor
A new instance of Agent.
Constructor Details
#initialize(id, name, deleted_at = nil, deleted: false) ⇒ Agent
Returns a new instance of Agent.
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/bloom_remit2/agent.rb', line 72 def initialize( id, name, deleted_at=nil, deleted: false ) @id = id @name = name @deleted_at = deleted_at @deleted = deleted end |
Instance Attribute Details
#deleted ⇒ Object (readonly)
Returns the value of attribute deleted.
70 71 72 |
# File 'lib/bloom_remit2/agent.rb', line 70 def deleted @deleted end |
#deleted_at ⇒ Object (readonly)
Returns the value of attribute deleted_at.
70 71 72 |
# File 'lib/bloom_remit2/agent.rb', line 70 def deleted_at @deleted_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
70 71 72 |
# File 'lib/bloom_remit2/agent.rb', line 70 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
70 71 72 |
# File 'lib/bloom_remit2/agent.rb', line 70 def name @name end |
Class Method Details
.create(name) ⇒ Object
Create a new agent under this partner
29 30 31 32 33 34 35 |
# File 'lib/bloom_remit2/agent.rb', line 29 def create(name) agent = Client.post(path, { agent: { name: name }}).with_indifferent_access new( agent[:id], agent[:name] ) end |
.delete(agent_id) ⇒ Object
Delete an agent belonging to this partner
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/bloom_remit2/agent.rb', line 52 def delete(agent_id) = Client.delete("#{path}/#{agent_id}").with_indifferent_access if [:success] == "We've successfully deleted that agent." new( agent_id, nil, deleted: true ) end end |
.list ⇒ Object
Show a list of agents belonging to this partner
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/bloom_remit2/agent.rb', line 5 def list agents = Client.get(path) agents.map do |agent| agent = agent.with_indifferent_access new( agent[:id], agent[:name], agent[:deleted_at] ) end end |
.retrieve(id) ⇒ Object
Show an agent belonging to this partner
19 20 21 22 23 24 25 |
# File 'lib/bloom_remit2/agent.rb', line 19 def retrieve(id) agent = Client.get("#{path}/#{id}").with_indifferent_access new( agent[:id], agent[:name] ) end |