Class: CircleSo::Client
- Inherits:
-
Object
- Object
- CircleSo::Client
- Defined in:
- lib/circle_so/client.rb
Overview
HTTP client for the Circle.so Admin API v2.
client = CircleSo::Client.new(token: ENV["CIRCLE_SO_TOKEN"])
client.community.show
client.community_members.invite(email: "user@example.com")
Zero runtime dependencies — built on Net::HTTP. All responses are parsed JSON (Hash/Array with string keys). Non-2xx responses raise a subclass of CircleSo::APIError (see errors.rb for the classification).
Constant Summary collapse
- BASE_URL =
"https://app.circle.so/api/admin/v2"
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
Instance Method Summary collapse
-
#access_groups ⇒ Object
-- resources ----------------------------------------------------------.
- #chat_preferences ⇒ Object
- #comments ⇒ Object
- #community ⇒ Object
- #community_members ⇒ Object
- #community_segments ⇒ Object
- #course_lessons ⇒ Object
- #course_sections ⇒ Object
- #delete(path, body = nil, params = {}) ⇒ Object
- #direct_uploads ⇒ Object
- #embeds ⇒ Object
- #event_attendees ⇒ Object
- #events ⇒ Object
- #flagged_contents ⇒ Object
- #forms ⇒ Object
- #gamification ⇒ Object
-
#get(path, params = {}) ⇒ Object
-- low-level requests (public escape hatch) ---------------------------.
- #images ⇒ Object
-
#initialize(token:, base_url: BASE_URL, open_timeout: 10, read_timeout: 60) ⇒ Client
constructor
A new instance of Client.
- #invitation_links ⇒ Object
- #member_tags ⇒ Object
- #messages ⇒ Object
- #page_profile_fields ⇒ Object
- #patch(path, body = nil, params = {}) ⇒ Object
- #post(path, body = nil, params = {}) ⇒ Object
- #posts ⇒ Object
- #profile_fields ⇒ Object
- #put(path, body = nil, params = {}) ⇒ Object
- #search ⇒ Object
- #space_group_members ⇒ Object
- #space_groups ⇒ Object
- #space_members ⇒ Object
- #spaces ⇒ Object
- #tagged_members ⇒ Object
- #topics ⇒ Object
Constructor Details
#initialize(token:, base_url: BASE_URL, open_timeout: 10, read_timeout: 60) ⇒ Client
Returns a new instance of Client.
22 23 24 25 26 27 28 29 |
# File 'lib/circle_so/client.rb', line 22 def initialize(token:, base_url: BASE_URL, open_timeout: 10, read_timeout: 60) raise ArgumentError, "token is required" if token.nil? || token.empty? @token = token @base_url = base_url.chomp("/") @open_timeout = open_timeout @read_timeout = read_timeout end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
20 21 22 |
# File 'lib/circle_so/client.rb', line 20 def base_url @base_url end |
Instance Method Details
#access_groups ⇒ Object
-- resources ----------------------------------------------------------
33 |
# File 'lib/circle_so/client.rb', line 33 def access_groups = @access_groups ||= Resources::AccessGroups.new(self) |
#chat_preferences ⇒ Object
34 |
# File 'lib/circle_so/client.rb', line 34 def chat_preferences = @chat_preferences ||= Resources::ChatPreferences.new(self) |
#comments ⇒ Object
35 |
# File 'lib/circle_so/client.rb', line 35 def comments = @comments ||= Resources::Comments.new(self) |
#community ⇒ Object
36 |
# File 'lib/circle_so/client.rb', line 36 def community = @community ||= Resources::Community.new(self) |
#community_members ⇒ Object
37 |
# File 'lib/circle_so/client.rb', line 37 def community_members = @community_members ||= Resources::CommunityMembers.new(self) |
#community_segments ⇒ Object
38 |
# File 'lib/circle_so/client.rb', line 38 def community_segments = @community_segments ||= Resources::CommunitySegments.new(self) |
#course_lessons ⇒ Object
39 |
# File 'lib/circle_so/client.rb', line 39 def course_lessons = @course_lessons ||= Resources::CourseLessons.new(self) |
#course_sections ⇒ Object
40 |
# File 'lib/circle_so/client.rb', line 40 def course_sections = @course_sections ||= Resources::CourseSections.new(self) |
#delete(path, body = nil, params = {}) ⇒ Object
69 |
# File 'lib/circle_so/client.rb', line 69 def delete(path, body = nil, params = {}) = request(Net::HTTP::Delete, path, body: body, params: params) |
#direct_uploads ⇒ Object
41 |
# File 'lib/circle_so/client.rb', line 41 def direct_uploads = @direct_uploads ||= Resources::DirectUploads.new(self) |
#embeds ⇒ Object
42 |
# File 'lib/circle_so/client.rb', line 42 def = @embeds ||= Resources::Embeds.new(self) |
#event_attendees ⇒ Object
43 |
# File 'lib/circle_so/client.rb', line 43 def event_attendees = @event_attendees ||= Resources::EventAttendees.new(self) |
#events ⇒ Object
44 |
# File 'lib/circle_so/client.rb', line 44 def events = @events ||= Resources::Events.new(self) |
#flagged_contents ⇒ Object
45 |
# File 'lib/circle_so/client.rb', line 45 def flagged_contents = @flagged_contents ||= Resources::FlaggedContents.new(self) |
#forms ⇒ Object
46 |
# File 'lib/circle_so/client.rb', line 46 def forms = @forms ||= Resources::Forms.new(self) |
#gamification ⇒ Object
47 |
# File 'lib/circle_so/client.rb', line 47 def gamification = @gamification ||= Resources::Gamification.new(self) |
#get(path, params = {}) ⇒ Object
-- low-level requests (public escape hatch) ---------------------------
65 |
# File 'lib/circle_so/client.rb', line 65 def get(path, params = {}) = request(Net::HTTP::Get, path, params: params) |
#images ⇒ Object
48 |
# File 'lib/circle_so/client.rb', line 48 def images = @images ||= Resources::Images.new(self) |
#invitation_links ⇒ Object
49 |
# File 'lib/circle_so/client.rb', line 49 def invitation_links = @invitation_links ||= Resources::InvitationLinks.new(self) |
#member_tags ⇒ Object
50 |
# File 'lib/circle_so/client.rb', line 50 def = @member_tags ||= Resources::MemberTags.new(self) |
#messages ⇒ Object
51 |
# File 'lib/circle_so/client.rb', line 51 def = @messages ||= Resources::Messages.new(self) |
#page_profile_fields ⇒ Object
52 |
# File 'lib/circle_so/client.rb', line 52 def page_profile_fields = @page_profile_fields ||= Resources::PageProfileFields.new(self) |
#patch(path, body = nil, params = {}) ⇒ Object
68 |
# File 'lib/circle_so/client.rb', line 68 def patch(path, body = nil, params = {}) = request(Net::HTTP::Patch, path, body: body, params: params) |
#post(path, body = nil, params = {}) ⇒ Object
66 |
# File 'lib/circle_so/client.rb', line 66 def post(path, body = nil, params = {}) = request(Net::HTTP::Post, path, body: body, params: params) |
#posts ⇒ Object
53 |
# File 'lib/circle_so/client.rb', line 53 def posts = @posts ||= Resources::Posts.new(self) |
#profile_fields ⇒ Object
54 |
# File 'lib/circle_so/client.rb', line 54 def profile_fields = @profile_fields ||= Resources::ProfileFields.new(self) |
#put(path, body = nil, params = {}) ⇒ Object
67 |
# File 'lib/circle_so/client.rb', line 67 def put(path, body = nil, params = {}) = request(Net::HTTP::Put, path, body: body, params: params) |
#search ⇒ Object
55 |
# File 'lib/circle_so/client.rb', line 55 def search = @search ||= Resources::Search.new(self) |
#space_group_members ⇒ Object
56 |
# File 'lib/circle_so/client.rb', line 56 def space_group_members = @space_group_members ||= Resources::SpaceGroupMembers.new(self) |
#space_groups ⇒ Object
57 |
# File 'lib/circle_so/client.rb', line 57 def space_groups = @space_groups ||= Resources::SpaceGroups.new(self) |
#space_members ⇒ Object
58 |
# File 'lib/circle_so/client.rb', line 58 def space_members = @space_members ||= Resources::SpaceMembers.new(self) |
#spaces ⇒ Object
59 |
# File 'lib/circle_so/client.rb', line 59 def spaces = @spaces ||= Resources::Spaces.new(self) |
#tagged_members ⇒ Object
60 |
# File 'lib/circle_so/client.rb', line 60 def tagged_members = @tagged_members ||= Resources::TaggedMembers.new(self) |