Class: RelayGrid::Resources::MessageTemplates
- Inherits:
-
Object
- Object
- RelayGrid::Resources::MessageTemplates
- Defined in:
- lib/relaygrid/resources/message_templates.rb
Overview
Read access to the account's templates. notify takes a template name,
so this is mostly for discovery -- listing what's available, or checking
which attributes a template expects before sending.
Instance Method Summary collapse
-
#find_by_name(name) ⇒ Hash?
Look a template up by the same name
notifytakes. - #get(id) ⇒ Hash
-
#initialize(client) ⇒ MessageTemplates
constructor
A new instance of MessageTemplates.
-
#list ⇒ Array<Hash>
Every template in the account.
Constructor Details
#initialize(client) ⇒ MessageTemplates
Returns a new instance of MessageTemplates.
9 10 11 |
# File 'lib/relaygrid/resources/message_templates.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#find_by_name(name) ⇒ Hash?
Look a template up by the same name notify takes.
28 29 30 |
# File 'lib/relaygrid/resources/message_templates.rb', line 28 def find_by_name(name) list.find { |template| template["name"] == name.to_s } end |
#get(id) ⇒ Hash
20 21 22 |
# File 'lib/relaygrid/resources/message_templates.rb', line 20 def get(id) @client.get("/api/v1/message_templates/#{id}")["message_template"] end |
#list ⇒ Array<Hash>
Returns every template in the account.
14 15 16 |
# File 'lib/relaygrid/resources/message_templates.rb', line 14 def list Array(@client.get("/api/v1/message_templates")["message_templates"]) end |