Class: CircleSo::Client

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(token:, base_url: BASE_URL, open_timeout: 10, read_timeout: 60) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


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_urlObject (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_groupsObject

-- resources ----------------------------------------------------------



33
# File 'lib/circle_so/client.rb', line 33

def access_groups = @access_groups ||= Resources::AccessGroups.new(self)

#chat_preferencesObject



34
# File 'lib/circle_so/client.rb', line 34

def chat_preferences = @chat_preferences ||= Resources::ChatPreferences.new(self)

#commentsObject



35
# File 'lib/circle_so/client.rb', line 35

def comments = @comments ||= Resources::Comments.new(self)

#communityObject



36
# File 'lib/circle_so/client.rb', line 36

def community = @community ||= Resources::Community.new(self)

#community_membersObject



37
# File 'lib/circle_so/client.rb', line 37

def community_members = @community_members ||= Resources::CommunityMembers.new(self)

#community_segmentsObject



38
# File 'lib/circle_so/client.rb', line 38

def community_segments = @community_segments ||= Resources::CommunitySegments.new(self)

#course_lessonsObject



39
# File 'lib/circle_so/client.rb', line 39

def course_lessons = @course_lessons ||= Resources::CourseLessons.new(self)

#course_sectionsObject



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_uploadsObject



41
# File 'lib/circle_so/client.rb', line 41

def direct_uploads = @direct_uploads ||= Resources::DirectUploads.new(self)

#embedsObject



42
# File 'lib/circle_so/client.rb', line 42

def embeds = @embeds ||= Resources::Embeds.new(self)

#event_attendeesObject



43
# File 'lib/circle_so/client.rb', line 43

def event_attendees = @event_attendees ||= Resources::EventAttendees.new(self)

#eventsObject



44
# File 'lib/circle_so/client.rb', line 44

def events = @events ||= Resources::Events.new(self)

#flagged_contentsObject



45
# File 'lib/circle_so/client.rb', line 45

def flagged_contents = @flagged_contents ||= Resources::FlaggedContents.new(self)

#formsObject



46
# File 'lib/circle_so/client.rb', line 46

def forms = @forms ||= Resources::Forms.new(self)

#gamificationObject



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)

#imagesObject



48
# File 'lib/circle_so/client.rb', line 48

def images = @images ||= Resources::Images.new(self)


49
# File 'lib/circle_so/client.rb', line 49

def invitation_links = @invitation_links ||= Resources::InvitationLinks.new(self)

#member_tagsObject



50
# File 'lib/circle_so/client.rb', line 50

def member_tags = @member_tags ||= Resources::MemberTags.new(self)

#messagesObject



51
# File 'lib/circle_so/client.rb', line 51

def messages = @messages ||= Resources::Messages.new(self)

#page_profile_fieldsObject



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)

#postsObject



53
# File 'lib/circle_so/client.rb', line 53

def posts = @posts ||= Resources::Posts.new(self)

#profile_fieldsObject



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)

#searchObject



55
# File 'lib/circle_so/client.rb', line 55

def search = @search ||= Resources::Search.new(self)

#space_group_membersObject



56
# File 'lib/circle_so/client.rb', line 56

def space_group_members = @space_group_members ||= Resources::SpaceGroupMembers.new(self)

#space_groupsObject



57
# File 'lib/circle_so/client.rb', line 57

def space_groups = @space_groups ||= Resources::SpaceGroups.new(self)

#space_membersObject



58
# File 'lib/circle_so/client.rb', line 58

def space_members = @space_members ||= Resources::SpaceMembers.new(self)

#spacesObject



59
# File 'lib/circle_so/client.rb', line 59

def spaces = @spaces ||= Resources::Spaces.new(self)

#tagged_membersObject



60
# File 'lib/circle_so/client.rb', line 60

def tagged_members = @tagged_members ||= Resources::TaggedMembers.new(self)

#topicsObject



61
# File 'lib/circle_so/client.rb', line 61

def topics = @topics ||= Resources::Topics.new(self)