Class: CircleOrbit::Interactions::Post
- Inherits:
-
Object
- Object
- CircleOrbit::Interactions::Post
- Defined in:
- lib/circle_orbit/interactions/post.rb
Instance Method Summary collapse
- #after_initialize! ⇒ Object
- #construct_body ⇒ Object
- #construct_description(title, body) ⇒ Object
-
#initialize(post_title:, body:, created_at:, id:, space:, url:, author:, email:, workspace_id:, api_key:) ⇒ Post
constructor
A new instance of Post.
Constructor Details
#initialize(post_title:, body:, created_at:, id:, space:, url:, author:, email:, workspace_id:, api_key:) ⇒ Post
Returns a new instance of Post.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/circle_orbit/interactions/post.rb', line 10 def initialize(post_title:, body:, created_at:, id:, space:, url:, author:, email:, workspace_id:, api_key:) @post_title = post_title @body = CircleOrbit::Utils.sanitize_body(body) @created_at = created_at @id = id @space = space @url = url @author = @email = email @workspace_id = workspace_id @api_key = api_key after_initialize! end |
Instance Method Details
#after_initialize! ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/circle_orbit/interactions/post.rb', line 25 def after_initialize! OrbitActivities::Request.new( api_key: @api_key, workspace_id: @workspace_id, user_agent: "community-ruby-circle-orbit/#{CircleOrbit::VERSION}", action: "new_activity", body: construct_body.to_json ) end |
#construct_body ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/circle_orbit/interactions/post.rb', line 35 def construct_body { activity: { activity_type: "circle:post", tags: ["channel:circle"], key: "circle-post-#{@id}", title: "New post in the #{@space} Space in Circle", description: construct_description(@post_title, @body), occurred_at: @created_at, link: @url, member: { name: @author, email: @email } }, identity: { source: "circle", email: @email } } end |
#construct_description(title, body) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/circle_orbit/interactions/post.rb', line 57 def construct_description(title, body) return body if title == "" || title.nil? <<~HEREDOC ## #{title} #{body} HEREDOC end |