Class: CircleOrbit::Circle
- Inherits:
-
Object
- Object
- CircleOrbit::Circle
- Defined in:
- lib/circle_orbit/circle.rb
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Circle
constructor
A new instance of Circle.
- #process_comments ⇒ Object
- #process_posts ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Circle
Returns a new instance of Circle.
5 6 7 8 9 10 11 12 |
# File 'lib/circle_orbit/circle.rb', line 5 def initialize(params = {}) @circle_api_key = params.fetch(:circle_api_key) @circle_community_id = params.fetch(:circle_community_id) @circle_url = params.fetch(:circle_url) @orbit_api_key = params.fetch(:orbit_api_key) @orbit_workspace = params.fetch(:orbit_workspace) @historical_import = params.fetch(:historical_import, false) end |
Instance Method Details
#process_comments ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/circle_orbit/circle.rb', line 51 def process_comments comments = get_comments return if comments.nil? || comments.empty? times = 0 = (type: "comment") comments.each do |comment| next if comment.nil? || comment.empty? unless @historical_import && next if comment["body"]["created_at"] < unless .nil? end if && @historical_import == false next if comment["body"]["created_at"] < end times += 1 CircleOrbit::Orbit.call( type: "comment", data: comment, orbit_api_key: @orbit_api_key, orbit_workspace: @orbit_workspace ) end output = "Sent #{times} new comments to your Orbit workspace" puts output return output end |
#process_posts ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/circle_orbit/circle.rb', line 14 def process_posts spaces = get_spaces spaces.each do |space| posts = get_posts(space["id"]) times = 0 = (type: "post") posts.each do |post| next if post.nil? || post.empty? unless @historical_import && next if post["created_at"] < unless .nil? end if && @historical_import == false next if post["created_at"] < end times += 1 CircleOrbit::Orbit.call( type: "post", data: post, orbit_api_key: @orbit_api_key, orbit_workspace: @orbit_workspace ) end output = "Sent #{times} new posts to your Orbit workspace" puts output return output end end |