class Glass::TimelineItem
Each item in the user’s timeline is represented as a TimelineItem
JSON structure, described below.
Constants
- DISPLAY_TIME
- WRITE_TIME
Attributes
The type of resource. This is always mirror#timelineItem.
A list of media attachments associated with this item.
The bundle ID for this item. Services can specify a bundleId to group many items together. They appear under a single top-level item on the device.
A canonical URL pointing to the canonical/high quality version of the data represented by the timeline item.
The Client
The time at which this item was created, formatted according to RFC 3339.
The user or group that created this item.
The time that should be displayed when this item is viewed in the timeline, formatted according to RFC 3339. This user’s timeline is sorted chronologically on display time, so this will also determine where the item is displayed in the timeline. If not set by the service, the display time defaults to the updated time.
ETag for this item.
HTML content for this item. If both text and html are provided for an item, the html will be rendered in the timeline.
Additional pages of HTML content associated with this item. If this field is specified, the item will be displayed as a bundle, with the html field as the cover. It is an error to specify this field without specifying the html field.
The ID of the timeline item. This is unique within a user’s timeline.
If this item was generated as a reply to another item, this field will be set to the ID of the item being replied to. This can be used to attach a reply to the appropriate conversation or post.
Whether this item is a bundle cover.
If an item is marked as a bundle cover, it will be the entry point to the bundle of items that have the same bundleId as that item. It will be shown only on the main timeline — not within the opened bundle.
On the main timeline, items that are shown are:
Items that have isBundleCover set to true Items that do not have a bundleId
Items that do not have a bundleId
In a bundle sub-timeline, items that are shown are: Items that have the bundleId in question AND isBundleCover set to false
When true, indicates this item is deleted, and only the ID property is set.
When true, indicates this item is pinned, which means it’s grouped alongside “active” items like navigation and hangouts, on the opposite side of the home screen from historical (non-pinned) timeline items.
The geographic location associated with this item.
Controls how notifications for this item are presented on the device. If this is missing, no notification will be generated.
For pinned items, this determines the order in which the item is displayed in the timeline, with a higher score appearing closer to the clock. Note: setting this field is currently not supported.
A list of contacts or groups that this item has been shared with.
A URL that can be used to retrieve this item.
Opaque string you can use to map a timeline item to data in your own service.
The speakable version of the content of this item. Along with the READ_ALOUD menu item, use this field to provide text that would be clearer when read aloud, or to provide extended information to what is displayed visually on Glass
.
Text content of this item.
The title of this item.
The time at which this item was last modified, formatted according to RFC 3339.
Public Class Methods
# File lib/glass/timeline/timeline_item.rb, line 21 def get(client, id) client.exexute( :api_method => client.timeline.get, :parameters => {:id => id} ) end
Retrieves a list of timeline items for the authenticated user. @param [string] bundleId
If true, tombstone records for deleted items will be returned.
@param [boolean] includeDeleted
If true, tombstone records for deleted items will be returned.
@param [integer] maxResults
The maximum number of items to include in the response, used for paging.
@param [string] orderBy
Controls the order in which timeline items are returned. Acceptable values are: "displayTime": Results will be ordered by displayTime (default). This is the same ordering as is used in the timeline on the device. "writeTime": Results will be ordered by the time at which they were last written to the data store.
@param [string] pageToken
Token for the page of results to return.
@param [boolean] pinnedOnly
If true, only pinned items will be returned.
@param [string] sourceItemId
If provided, only items with the given sourceItemId will be returned.
# File lib/glass/timeline/timeline_item.rb, line 50 def list(client, params={}) result=[] parameters = params api_result = client.execute( :api_method => mirror.timeline.list, :parameters => parameters) if api_result.success? data = api_result.data unless data.items.empty? result << data.items parameters[:pageToken]= data.next_page_token result << list(client, parameters) end else puts "An error occurred: #{result.data['error']['message']}" end result end
# File lib/glass/timeline/timeline_item.rb, line 10 def initialize(client=nil) @client = client end
Public Instance Methods
# File lib/glass/timeline/timeline_item.rb, line 389 def file_to_upload file_to_upload=[] @attachments.each { |attachment| file_to_upload << attachment unless attachment.id } file_to_upload end
# File lib/glass/timeline/timeline_item.rb, line 381 def file_upload? flag=false @attachments.each { |attachment| flag = true unless attachment.id } return flag end
Insert a new Timeline Item in the user’s glass.
@param [Google::APIClient::API] client
Authorized client instance.
@return Array
Timeline item instance if successful, nil otherwise.
# File lib/glass/timeline/timeline_item.rb, line 359 def insert!(mirror=@client) timeline_item = self result = [] if file_upload? for file in file_to_upload media = Google::APIClient::UploadIO.new(file.contentUrl, file.content_type) result << client.execute!( :api_method => mirror.timeline.insert, :body_object => timeline_item, :media => media, :parameters => { :uploadType => 'multipart', :alt => 'json'}) end else result << client.execute( :api_method => mirror.timeline.insert, :body_object => timeline_item) end return result.data end