Class: Monzo::FeedItem
- Inherits:
-
Object
- Object
- Monzo::FeedItem
- Defined in:
- lib/monzo/feed_item.rb
Overview
Public: The Monzo app is organised around the feed – a
reverse-chronological stream of events. Transactions
are one such feed item, and your application can
create its own feed items to surface relevant information
to the user.
Instance Attribute Summary collapse
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
-
.create(account_id, type, params, url = nil) ⇒ Object
Public: Create a feed item on a user’s feed.
Instance Method Summary collapse
-
#initialize(params) ⇒ FeedItem
constructor
Public: Initialize a FeedItem.
Constructor Details
#initialize(params) ⇒ FeedItem
Public: Initialize a FeedItem.
params - A Hash of feed item parameters.
15 16 17 18 19 20 |
# File 'lib/monzo/feed_item.rb', line 15 def initialize(params) @account_id = params[:account_id] @type = params[:type] @params = params[:params] @url = params[:url] end |
Instance Attribute Details
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
10 11 12 |
# File 'lib/monzo/feed_item.rb', line 10 def account_id @account_id end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/monzo/feed_item.rb', line 10 def params @params end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/monzo/feed_item.rb', line 10 def type @type end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/monzo/feed_item.rb', line 10 def url @url end |
Class Method Details
.create(account_id, type, params, url = nil) ⇒ Object
Public: Create a feed item on a user’s feed.
account_id - The account id to create a feed item for. type - Type of feed item. Currently only basic is supported. params - A Hash of parameters which vary based on type. url - A URL to open when the feed item is tapped.
If no URL is provided, the app will display a fallback
view based on the title & body. (optional)
Returns: An empty Hash.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/monzo/feed_item.rb', line 32 def self.create(account_id, type, params, url = nil) client = Monzo.client data = { "account_id" => account_id, "type" => type, "params[title]" => params[:title], "params[image_url]" => params[:image_url], "params[background_color]" => params[:background_color], "params[body_color]" => params[:body_color], "params[title_color]" => params[:title_color], "params[body]" => params[:body], "url" => url } response = client.post("/feed", data, {}) JSON.parse(response.body, :symbolize_names => true) end |