mangoapps-ex-sdk-ruby 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +506 -0
- data/LICENSE +201 -0
- data/README.md +2040 -0
- data/lib/mangoapps/client.rb +219 -0
- data/lib/mangoapps/config.rb +98 -0
- data/lib/mangoapps/errors.rb +45 -0
- data/lib/mangoapps/modules/attachments/get_folder_files.rb +14 -0
- data/lib/mangoapps/modules/attachments/get_folders.rb +14 -0
- data/lib/mangoapps/modules/attachments.rb +14 -0
- data/lib/mangoapps/modules/feeds/feeds.rb +14 -0
- data/lib/mangoapps/modules/feeds.rb +12 -0
- data/lib/mangoapps/modules/learn/course_catalog.rb +16 -0
- data/lib/mangoapps/modules/learn/course_categories.rb +16 -0
- data/lib/mangoapps/modules/learn/course_details.rb +13 -0
- data/lib/mangoapps/modules/learn/my_learning.rb +13 -0
- data/lib/mangoapps/modules/learn.rb +18 -0
- data/lib/mangoapps/modules/libraries/get_libraries.rb +14 -0
- data/lib/mangoapps/modules/libraries/get_library_categories.rb +14 -0
- data/lib/mangoapps/modules/libraries/get_library_items.rb +14 -0
- data/lib/mangoapps/modules/libraries.rb +16 -0
- data/lib/mangoapps/modules/notifications/my_priority_items.rb +13 -0
- data/lib/mangoapps/modules/notifications/notifications.rb +14 -0
- data/lib/mangoapps/modules/notifications.rb +14 -0
- data/lib/mangoapps/modules/posts/get_all_posts.rb +14 -0
- data/lib/mangoapps/modules/posts/get_post_by_id.rb +13 -0
- data/lib/mangoapps/modules/posts.rb +14 -0
- data/lib/mangoapps/modules/recognitions/award_categories.rb +14 -0
- data/lib/mangoapps/modules/recognitions/core_value_tags.rb +13 -0
- data/lib/mangoapps/modules/recognitions/get_award_feeds.rb +14 -0
- data/lib/mangoapps/modules/recognitions/get_awards_list.rb +14 -0
- data/lib/mangoapps/modules/recognitions/get_profile_awards.rb +13 -0
- data/lib/mangoapps/modules/recognitions/get_team_awards.rb +13 -0
- data/lib/mangoapps/modules/recognitions/gift_cards.rb +13 -0
- data/lib/mangoapps/modules/recognitions/leaderboard_info.rb +13 -0
- data/lib/mangoapps/modules/recognitions.rb +26 -0
- data/lib/mangoapps/modules/tasks/get_task_details.rb +13 -0
- data/lib/mangoapps/modules/tasks/get_tasks.rb +14 -0
- data/lib/mangoapps/modules/tasks.rb +14 -0
- data/lib/mangoapps/modules/trackers/get_trackers.rb +14 -0
- data/lib/mangoapps/modules/trackers.rb +12 -0
- data/lib/mangoapps/modules/users.rb +11 -0
- data/lib/mangoapps/modules/wikis/get_wiki_details.rb +13 -0
- data/lib/mangoapps/modules/wikis/get_wikis.rb +14 -0
- data/lib/mangoapps/modules/wikis.rb +14 -0
- data/lib/mangoapps/oauth.rb +187 -0
- data/lib/mangoapps/response.rb +92 -0
- data/lib/mangoapps/version.rb +5 -0
- data/lib/mangoapps.rb +34 -0
- metadata +181 -0
@@ -0,0 +1,219 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "faraday"
|
4
|
+
require "faraday/retry"
|
5
|
+
require "multi_json"
|
6
|
+
require "ostruct"
|
7
|
+
|
8
|
+
module MangoApps
|
9
|
+
class Client
|
10
|
+
attr_reader :config, :http, :oauth
|
11
|
+
|
12
|
+
def initialize(config)
|
13
|
+
@config = config
|
14
|
+
@oauth = OAuth.new(config)
|
15
|
+
@http = build_http_client
|
16
|
+
end
|
17
|
+
|
18
|
+
# ---- Authentication ----
|
19
|
+
def access_token
|
20
|
+
@access_token ||= load_access_token
|
21
|
+
end
|
22
|
+
|
23
|
+
def authenticated?
|
24
|
+
access_token && !token_expired?
|
25
|
+
end
|
26
|
+
|
27
|
+
def authenticate!(authorization_code:, code_verifier: nil)
|
28
|
+
@access_token = oauth.get_token(
|
29
|
+
authorization_code: authorization_code,
|
30
|
+
code_verifier: code_verifier
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def refresh_token!
|
35
|
+
raise MangoApps::TokenExpiredError, "No refresh token available" unless access_token&.refresh_token
|
36
|
+
|
37
|
+
@access_token = oauth.refresh!(access_token)
|
38
|
+
end
|
39
|
+
|
40
|
+
# ---- HTTP Methods ----
|
41
|
+
def get(path, params: {}, headers: {})
|
42
|
+
request(:get, path, params: params, headers: headers)
|
43
|
+
end
|
44
|
+
|
45
|
+
def post(path, body: nil, headers: {})
|
46
|
+
request(:post, path, body: body, headers: headers)
|
47
|
+
end
|
48
|
+
|
49
|
+
def put(path, body: nil, headers: {})
|
50
|
+
request(:put, path, body: body, headers: headers)
|
51
|
+
end
|
52
|
+
|
53
|
+
def delete(path, headers: {})
|
54
|
+
request(:delete, path, headers: headers)
|
55
|
+
end
|
56
|
+
|
57
|
+
# ---- OAuth Helpers ----
|
58
|
+
def authorization_url(state:, code_challenge: nil, code_challenge_method: "S256", **extra_params)
|
59
|
+
oauth.authorization_url(
|
60
|
+
state: state,
|
61
|
+
code_challenge: code_challenge,
|
62
|
+
code_challenge_method: code_challenge_method,
|
63
|
+
extra_params: extra_params
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_userinfo
|
68
|
+
case config.authentication_method
|
69
|
+
when :internal_api
|
70
|
+
# For internal API, we can't use OAuth userinfo endpoint
|
71
|
+
# Instead, we'll use the /me endpoint which provides user info
|
72
|
+
response = get("v2/me.json")
|
73
|
+
response.user_profile.minimal_profile
|
74
|
+
when :oauth
|
75
|
+
raise MangoApps::TokenExpiredError, "No access token available" unless access_token
|
76
|
+
|
77
|
+
userinfo_data = oauth.get_userinfo(access_token.token)
|
78
|
+
MangoApps::Response.new(userinfo_data)
|
79
|
+
else
|
80
|
+
raise MangoApps::AuthenticationError, "No authentication method available"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def build_http_client
|
87
|
+
Faraday.new(url: config.api_base) do |f|
|
88
|
+
f.request :retry, retry_options
|
89
|
+
f.request :json
|
90
|
+
f.response :json, content_type: /\bjson$/
|
91
|
+
f.options.timeout = config.timeout
|
92
|
+
f.options.open_timeout = config.open_timeout
|
93
|
+
f.response :logger, config.logger if config.logger
|
94
|
+
f.adapter Faraday.default_adapter
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def retry_options
|
99
|
+
{
|
100
|
+
max: 3,
|
101
|
+
interval: 0.3,
|
102
|
+
backoff_factor: 2,
|
103
|
+
methods: %i[get post put delete],
|
104
|
+
exceptions: [Faraday::TimeoutError, Faraday::ConnectionFailed],
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
def request(method, path, params: nil, body: nil, headers: {})
|
109
|
+
ensure_authenticated!
|
110
|
+
|
111
|
+
# Store request details for error reporting
|
112
|
+
request_details = {
|
113
|
+
method: method.to_s.upcase,
|
114
|
+
url: "#{config.api_base}#{path}",
|
115
|
+
params: params,
|
116
|
+
body: body,
|
117
|
+
headers: auth_headers.merge(headers)
|
118
|
+
}
|
119
|
+
|
120
|
+
response = http.run_request(
|
121
|
+
method,
|
122
|
+
path,
|
123
|
+
(body.nil? ? nil : MultiJson.dump(body)),
|
124
|
+
auth_headers.merge(headers)
|
125
|
+
) do |req|
|
126
|
+
req.params.update(params) if params
|
127
|
+
end
|
128
|
+
|
129
|
+
return wrap_response(response.body) if response.success?
|
130
|
+
|
131
|
+
handle_error_response(response, request_details)
|
132
|
+
end
|
133
|
+
|
134
|
+
def auth_headers
|
135
|
+
case config.authentication_method
|
136
|
+
when :internal_api
|
137
|
+
headers = {
|
138
|
+
"Internal-Api-Key" => config.internal_api_key,
|
139
|
+
"Internal-Api-Secret" => config.internal_api_secret
|
140
|
+
}
|
141
|
+
headers
|
142
|
+
when :oauth
|
143
|
+
{ "Authorization" => "Bearer #{access_token.token}" }
|
144
|
+
else
|
145
|
+
{}
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def ensure_authenticated!
|
150
|
+
return if authenticated? || config.has_internal_api_credentials?
|
151
|
+
|
152
|
+
raise MangoApps::AuthenticationError, "Not authenticated. Complete OAuth flow or provide internal API credentials."
|
153
|
+
end
|
154
|
+
|
155
|
+
def load_access_token
|
156
|
+
# First try to use stored token from .env
|
157
|
+
if config.has_valid_token?
|
158
|
+
# Create a simple token object from stored token
|
159
|
+
stored_token = OpenStruct.new(
|
160
|
+
token: config.access_token,
|
161
|
+
refresh_token: config.refresh_token,
|
162
|
+
expires_at: ENV["MANGOAPPS_TOKEN_EXPIRES_AT"]&.to_i
|
163
|
+
)
|
164
|
+
return stored_token
|
165
|
+
end
|
166
|
+
|
167
|
+
# Fallback to oauth token store
|
168
|
+
oauth.load_token
|
169
|
+
end
|
170
|
+
|
171
|
+
def token_expired?
|
172
|
+
return true unless access_token
|
173
|
+
|
174
|
+
# Check if token expires within the next 5 minutes
|
175
|
+
if access_token.expires_at
|
176
|
+
expires_at = access_token.expires_at.is_a?(Integer) ? Time.at(access_token.expires_at) : access_token.expires_at
|
177
|
+
expires_at < (Time.now + 300)
|
178
|
+
else
|
179
|
+
false
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def handle_error_response(response, request_details = nil)
|
184
|
+
error_class = case response.status
|
185
|
+
when 400 then MangoApps::BadRequestError
|
186
|
+
when 401 then MangoApps::UnauthorizedError
|
187
|
+
when 403 then MangoApps::ForbiddenError
|
188
|
+
when 404 then MangoApps::NotFoundError
|
189
|
+
when 429 then MangoApps::RateLimitError
|
190
|
+
when 500..599 then MangoApps::ServerError
|
191
|
+
else MangoApps::APIError
|
192
|
+
end
|
193
|
+
|
194
|
+
error_message = extract_error_message(response)
|
195
|
+
raise error_class.new(
|
196
|
+
error_message,
|
197
|
+
status_code: response.status,
|
198
|
+
response_body: response.body,
|
199
|
+
request_details: request_details
|
200
|
+
)
|
201
|
+
end
|
202
|
+
|
203
|
+
def wrap_response(data)
|
204
|
+
return data unless data.is_a?(Hash)
|
205
|
+
|
206
|
+
MangoApps::Response.new(data)
|
207
|
+
end
|
208
|
+
|
209
|
+
def extract_error_message(response)
|
210
|
+
if response.body.is_a?(Hash) && response.body["error"]
|
211
|
+
response.body["error"]
|
212
|
+
elsif response.body.is_a?(Hash) && response.body["message"]
|
213
|
+
response.body["message"]
|
214
|
+
else
|
215
|
+
"MangoApps API error: #{response.status}"
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dotenv"
|
4
|
+
|
5
|
+
module MangoApps
|
6
|
+
class Config
|
7
|
+
attr_accessor :domain, :client_id, :client_secret, :redirect_uri, :scope,
|
8
|
+
:token_store, :timeout, :open_timeout, :logger, :access_token, :refresh_token,
|
9
|
+
:internal_api_key, :internal_api_secret, :test_header
|
10
|
+
|
11
|
+
def initialize(domain: nil, client_id: nil, client_secret: nil, redirect_uri: nil, scope: nil, # rubocop:disable Metrics/ParameterLists
|
12
|
+
token_store: nil, timeout: 30, open_timeout: 10, logger: nil,
|
13
|
+
internal_api_key: nil, internal_api_secret: nil, test_header: nil)
|
14
|
+
# Load environment variables from .env file
|
15
|
+
Dotenv.load if File.exist?(".env")
|
16
|
+
|
17
|
+
@domain = domain || ENV.fetch("MANGOAPPS_DOMAIN", nil)
|
18
|
+
@client_id = client_id || ENV.fetch("MANGOAPPS_CLIENT_ID", nil)
|
19
|
+
@client_secret = client_secret || ENV.fetch("MANGOAPPS_CLIENT_SECRET", nil)
|
20
|
+
@redirect_uri = redirect_uri || ENV["MANGOAPPS_REDIRECT_URI"] || "https://localhost:3000/oauth/callback"
|
21
|
+
@scope = scope || ENV["MANGOAPPS_SCOPE"] || "openid profile email"
|
22
|
+
@access_token = ENV["MANGOAPPS_ACCESS_TOKEN"]
|
23
|
+
@refresh_token = ENV["MANGOAPPS_REFRESH_TOKEN"]
|
24
|
+
@internal_api_key = internal_api_key || ENV["MANGOAPPS_INTERNAL_API_KEY"]
|
25
|
+
@internal_api_secret = internal_api_secret || ENV["MANGOAPPS_INTERNAL_API_SECRET"]
|
26
|
+
@test_header = test_header || ENV["MANGOAPPS_TEST_HEADER"]
|
27
|
+
@token_store = token_store
|
28
|
+
@timeout = timeout
|
29
|
+
@open_timeout = open_timeout
|
30
|
+
@logger = logger
|
31
|
+
|
32
|
+
validate_required_fields!
|
33
|
+
|
34
|
+
# Show authentication method being used
|
35
|
+
show_authentication_method
|
36
|
+
end
|
37
|
+
|
38
|
+
def base_url = "https://#{domain}"
|
39
|
+
def api_base = "#{base_url}/api/"
|
40
|
+
|
41
|
+
def token_expired?
|
42
|
+
return true unless ENV["MANGOAPPS_TOKEN_EXPIRES_AT"]
|
43
|
+
Time.now.to_i >= ENV["MANGOAPPS_TOKEN_EXPIRES_AT"].to_i
|
44
|
+
end
|
45
|
+
|
46
|
+
def has_valid_token?
|
47
|
+
@access_token && !token_expired?
|
48
|
+
end
|
49
|
+
|
50
|
+
def has_internal_api_credentials?
|
51
|
+
@internal_api_key && @internal_api_secret && !@internal_api_key.empty? && !@internal_api_secret.empty?
|
52
|
+
end
|
53
|
+
|
54
|
+
def authentication_method
|
55
|
+
if has_internal_api_credentials?
|
56
|
+
:internal_api
|
57
|
+
elsif has_valid_token?
|
58
|
+
:oauth
|
59
|
+
else
|
60
|
+
:none
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def show_authentication_method
|
65
|
+
case authentication_method
|
66
|
+
when :internal_api
|
67
|
+
puts "🔑 Using Internal API authentication"
|
68
|
+
puts " Domain: #{@domain}"
|
69
|
+
puts " API Key: #{@internal_api_key[0..7]}..."
|
70
|
+
when :oauth
|
71
|
+
puts "🔐 Using OAuth2 authentication"
|
72
|
+
puts " Domain: #{@domain}"
|
73
|
+
puts " Client ID: #{@client_id[0..7]}..."
|
74
|
+
puts " Redirect URI: #{@redirect_uri}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def validate_required_fields!
|
81
|
+
missing_fields = []
|
82
|
+
missing_fields << "domain" if @domain.nil? || @domain.empty?
|
83
|
+
|
84
|
+
# Check if we have either OAuth or Internal API credentials
|
85
|
+
has_oauth = @client_id && @client_secret && !@client_id.empty? && !@client_secret.empty?
|
86
|
+
has_internal_api = has_internal_api_credentials?
|
87
|
+
|
88
|
+
unless has_oauth || has_internal_api
|
89
|
+
missing_fields << "authentication credentials (either OAuth client_id/client_secret or internal_api_key/internal_api_secret)"
|
90
|
+
end
|
91
|
+
|
92
|
+
if missing_fields.any?
|
93
|
+
raise ArgumentError, "Missing required configuration: #{missing_fields.join(', ')}. " \
|
94
|
+
"Set environment variables or pass as parameters."
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MangoApps
|
4
|
+
# Base error class for all MangoApps SDK errors
|
5
|
+
class Error < StandardError; end
|
6
|
+
|
7
|
+
# Configuration related errors
|
8
|
+
class ConfigurationError < Error; end
|
9
|
+
|
10
|
+
# Authentication related errors
|
11
|
+
class AuthenticationError < Error; end
|
12
|
+
class TokenExpiredError < AuthenticationError; end
|
13
|
+
class InvalidCredentialsError < AuthenticationError; end
|
14
|
+
|
15
|
+
# OAuth/OIDC related errors
|
16
|
+
class OAuthError < Error; end
|
17
|
+
class DiscoveryError < OAuthError; end
|
18
|
+
class TokenExchangeError < OAuthError; end
|
19
|
+
|
20
|
+
# API related errors
|
21
|
+
class APIError < Error
|
22
|
+
attr_reader :status_code, :response_body, :request_details
|
23
|
+
|
24
|
+
def initialize(message, status_code: nil, response_body: nil, request_details: nil)
|
25
|
+
super(message)
|
26
|
+
@status_code = status_code
|
27
|
+
@response_body = response_body
|
28
|
+
@request_details = request_details
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# HTTP related errors
|
33
|
+
class HTTPError < APIError; end
|
34
|
+
class BadRequestError < APIError; end
|
35
|
+
class UnauthorizedError < APIError; end
|
36
|
+
class ForbiddenError < APIError; end
|
37
|
+
class NotFoundError < APIError; end
|
38
|
+
class RateLimitError < APIError; end
|
39
|
+
class ServerError < APIError; end
|
40
|
+
|
41
|
+
# Client related errors
|
42
|
+
class ClientError < Error; end
|
43
|
+
class TimeoutError < ClientError; end
|
44
|
+
class ConnectionError < ClientError; end
|
45
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MangoApps
|
4
|
+
class Client
|
5
|
+
module Attachments
|
6
|
+
module GetFolderFiles
|
7
|
+
def get_folder_files(folder_id, include_folders: "Y", page: 1, limit: 20, params: {})
|
8
|
+
params = params.merge(include_folders: include_folders, page: page, limit: limit)
|
9
|
+
get("folders/#{folder_id}/files.json", params: params)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MangoApps
|
4
|
+
class Client
|
5
|
+
module Attachments
|
6
|
+
module GetFolders
|
7
|
+
def get_folders(page: 1, limit: 20, params: {})
|
8
|
+
params = params.merge(page: page, limit: limit)
|
9
|
+
get("folders.json", params: params)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "attachments/get_folders"
|
4
|
+
require_relative "attachments/get_folder_files"
|
5
|
+
|
6
|
+
module MangoApps
|
7
|
+
class Client
|
8
|
+
module Attachments
|
9
|
+
# Include all attachments sub-modules
|
10
|
+
include MangoApps::Client::Attachments::GetFolders
|
11
|
+
include MangoApps::Client::Attachments::GetFolderFiles
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MangoApps
|
4
|
+
class Client
|
5
|
+
module Feeds
|
6
|
+
module Feeds
|
7
|
+
def feeds(page: 1, limit: 20, params: {})
|
8
|
+
params = params.merge(page: page, limit: limit)
|
9
|
+
get("feeds.json", params: params)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MangoApps
|
4
|
+
class Client
|
5
|
+
module Learn
|
6
|
+
module CourseCatalog
|
7
|
+
# Get course catalog from MangoApps Learn API
|
8
|
+
# GET /api/v2/learn/course_catalog.json
|
9
|
+
def course_catalog(page: 1, limit: 20, params: {})
|
10
|
+
params = params.merge(page: page, limit: limit)
|
11
|
+
get("v2/learn/course_catalog.json", params: params)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MangoApps
|
4
|
+
class Client
|
5
|
+
module Learn
|
6
|
+
module CourseCategories
|
7
|
+
# Get course categories from MangoApps Learn API
|
8
|
+
# GET /api/v2/learn/course_categories.json
|
9
|
+
def course_categories(page: 1, limit: 20, params: {})
|
10
|
+
params = params.merge(page: page, limit: limit)
|
11
|
+
get("v2/learn/course_categories.json", params: params)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "learn/course_catalog"
|
4
|
+
require_relative "learn/course_categories"
|
5
|
+
require_relative "learn/course_details"
|
6
|
+
require_relative "learn/my_learning"
|
7
|
+
|
8
|
+
module MangoApps
|
9
|
+
class Client
|
10
|
+
module Learn
|
11
|
+
# Include all learn sub-modules
|
12
|
+
include MangoApps::Client::Learn::CourseCatalog
|
13
|
+
include MangoApps::Client::Learn::CourseCategories
|
14
|
+
include MangoApps::Client::Learn::CourseDetails
|
15
|
+
include MangoApps::Client::Learn::MyLearning
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MangoApps
|
4
|
+
class Client
|
5
|
+
module Libraries
|
6
|
+
module GetLibraries
|
7
|
+
def get_libraries(page: 1, limit: 20, params: {})
|
8
|
+
params = params.merge(page: page, limit: limit)
|
9
|
+
get("users/libraries/get_libraries.json", params: params)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MangoApps
|
4
|
+
class Client
|
5
|
+
module Libraries
|
6
|
+
module GetLibraryCategories
|
7
|
+
def get_library_categories(library_id, page: 1, limit: 20, params: {})
|
8
|
+
params = params.merge(page: page, limit: limit)
|
9
|
+
get("users/libraries/#{library_id}.json", params: params)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MangoApps
|
4
|
+
class Client
|
5
|
+
module Libraries
|
6
|
+
module GetLibraryItems
|
7
|
+
def get_library_items(library_id, category_id, page: 1, limit: 20, params: {})
|
8
|
+
params = params.merge(page: page, limit: limit)
|
9
|
+
get("users/libraries/#{library_id}/categories/#{category_id}/library_items/get_library_items.json", params: params)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "libraries/get_libraries"
|
4
|
+
require_relative "libraries/get_library_categories"
|
5
|
+
require_relative "libraries/get_library_items"
|
6
|
+
|
7
|
+
module MangoApps
|
8
|
+
class Client
|
9
|
+
module Libraries
|
10
|
+
# Include all libraries sub-modules
|
11
|
+
include MangoApps::Client::Libraries::GetLibraries
|
12
|
+
include MangoApps::Client::Libraries::GetLibraryCategories
|
13
|
+
include MangoApps::Client::Libraries::GetLibraryItems
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MangoApps
|
4
|
+
class Client
|
5
|
+
module Notifications
|
6
|
+
module Notifications
|
7
|
+
def notifications(page: 1, limit: 20, params: {})
|
8
|
+
params = params.merge(page: page, limit: limit)
|
9
|
+
get("users/notifications.json", params: params)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "notifications/my_priority_items"
|
4
|
+
require_relative "notifications/notifications"
|
5
|
+
|
6
|
+
module MangoApps
|
7
|
+
class Client
|
8
|
+
module Notifications
|
9
|
+
# Include all notifications sub-modules
|
10
|
+
include MangoApps::Client::Notifications::MyPriorityItems
|
11
|
+
include MangoApps::Client::Notifications::Notifications
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MangoApps
|
4
|
+
class Client
|
5
|
+
module Posts
|
6
|
+
module GetAllPosts
|
7
|
+
def get_all_posts(filter_by: "all", page: 1, limit: 20, params: {})
|
8
|
+
params = params.merge(filter_by: filter_by, page: page, limit: limit)
|
9
|
+
get("posts/get_all_posts.json", params: params)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "posts/get_all_posts"
|
4
|
+
require_relative "posts/get_post_by_id"
|
5
|
+
|
6
|
+
module MangoApps
|
7
|
+
class Client
|
8
|
+
module Posts
|
9
|
+
# Include all posts sub-modules
|
10
|
+
include MangoApps::Client::Posts::GetAllPosts
|
11
|
+
include MangoApps::Client::Posts::GetPostById
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|