mangoapps-ex-sdk-ruby 19.1.1 → 19.1.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.
@@ -38,20 +38,20 @@ module MangoApps
38
38
  end
39
39
 
40
40
  # ---- HTTP Methods ----
41
- def get(path, params: {}, headers: {})
42
- request(:get, path, params: params, headers: headers)
41
+ def get(path, params: {}, headers: {}, unique_user_id: nil)
42
+ request(:get, path, params: params, headers: headers, unique_user_id: unique_user_id)
43
43
  end
44
44
 
45
- def post(path, body: nil, headers: {})
46
- request(:post, path, body: body, headers: headers)
45
+ def post(path, body: nil, headers: {}, unique_user_id: nil)
46
+ request(:post, path, body: body, headers: headers, unique_user_id: unique_user_id)
47
47
  end
48
48
 
49
- def put(path, body: nil, headers: {})
50
- request(:put, path, body: body, headers: headers)
49
+ def put(path, body: nil, headers: {}, unique_user_id: nil)
50
+ request(:put, path, body: body, headers: headers, unique_user_id: unique_user_id)
51
51
  end
52
52
 
53
- def delete(path, headers: {})
54
- request(:delete, path, headers: headers)
53
+ def delete(path, headers: {}, unique_user_id: nil)
54
+ request(:delete, path, headers: headers, unique_user_id: unique_user_id)
55
55
  end
56
56
 
57
57
  # ---- OAuth Helpers ----
@@ -64,12 +64,12 @@ module MangoApps
64
64
  )
65
65
  end
66
66
 
67
- def get_userinfo
67
+ def get_userinfo(unique_user_id: nil)
68
68
  case config.authentication_method
69
69
  when :internal_api
70
70
  # For internal API, we can't use OAuth userinfo endpoint
71
71
  # Instead, we'll use the /me endpoint which provides user info
72
- response = get("v2/me.json")
72
+ response = get("v2/me.json", unique_user_id: unique_user_id)
73
73
  response.user_profile.minimal_profile
74
74
  when :oauth
75
75
  raise MangoApps::TokenExpiredError, "No access token available" unless access_token
@@ -105,23 +105,26 @@ module MangoApps
105
105
  }
106
106
  end
107
107
 
108
- def request(method, path, params: nil, body: nil, headers: {})
108
+ def request(method, path, params: nil, body: nil, headers: {}, unique_user_id: nil)
109
109
  ensure_authenticated!
110
110
 
111
+ # Build headers with optional unique_user_id
112
+ request_headers = auth_headers(unique_user_id: unique_user_id).merge(headers)
113
+
111
114
  # Store request details for error reporting
112
115
  request_details = {
113
116
  method: method.to_s.upcase,
114
117
  url: "#{config.api_base}#{path}",
115
118
  params: params,
116
119
  body: body,
117
- headers: auth_headers.merge(headers)
120
+ headers: request_headers
118
121
  }
119
122
 
120
123
  response = http.run_request(
121
124
  method,
122
125
  path,
123
126
  (body.nil? ? nil : MultiJson.dump(body)),
124
- auth_headers.merge(headers)
127
+ request_headers
125
128
  ) do |req|
126
129
  req.params.update(params) if params
127
130
  end
@@ -131,13 +134,20 @@ module MangoApps
131
134
  handle_error_response(response, request_details)
132
135
  end
133
136
 
134
- def auth_headers
137
+ def auth_headers(unique_user_id: nil)
135
138
  case config.authentication_method
136
139
  when :internal_api
137
140
  headers = {
138
141
  "Internal-Api-Key" => config.internal_api_key,
139
142
  "Internal-Api-Secret" => config.internal_api_secret
140
143
  }
144
+ # Add Internal-Api-Email-Id header if unique_user_id is provided
145
+ if unique_user_id
146
+ headers["Internal-Api-Email-Id"] = unique_user_id
147
+ elsif config.internal_api_email_id
148
+ # Fallback to config-level email ID if no unique_user_id provided
149
+ headers["Internal-Api-Email-Id"] = config.internal_api_email_id
150
+ end
141
151
  headers
142
152
  when :oauth
143
153
  { "Authorization" => "Bearer #{access_token.token}" }
@@ -6,11 +6,11 @@ module MangoApps
6
6
  class Config
7
7
  attr_accessor :domain, :client_id, :client_secret, :redirect_uri, :scope,
8
8
  :token_store, :timeout, :open_timeout, :logger, :access_token, :refresh_token,
9
- :internal_api_key, :internal_api_secret
9
+ :internal_api_key, :internal_api_secret, :internal_api_email_id
10
10
 
11
11
  def initialize(domain: nil, client_id: nil, client_secret: nil, redirect_uri: nil, scope: nil, # rubocop:disable Metrics/ParameterLists
12
12
  token_store: nil, timeout: 30, open_timeout: 10, logger: nil,
13
- internal_api_key: nil, internal_api_secret: nil)
13
+ internal_api_key: nil, internal_api_secret: nil, internal_api_email_id: nil)
14
14
  # Load environment variables from .env file
15
15
  Dotenv.load if File.exist?(".env")
16
16
 
@@ -23,6 +23,7 @@ module MangoApps
23
23
  @refresh_token = ENV["MANGOAPPS_REFRESH_TOKEN"]
24
24
  @internal_api_key = internal_api_key || ENV["MANGOAPPS_INTERNAL_API_KEY"]
25
25
  @internal_api_secret = internal_api_secret || ENV["MANGOAPPS_INTERNAL_API_SECRET"]
26
+ @internal_api_email_id = internal_api_email_id || ENV["MANGOAPPS_INTERNAL_API_EMAIL_ID"]
26
27
  @token_store = token_store
27
28
  @timeout = timeout
28
29
  @open_timeout = open_timeout
@@ -4,8 +4,8 @@ module MangoApps
4
4
  class Client
5
5
  module Feeds
6
6
  module Feeds
7
- def get_feeds(offset: 0, limit: 20, all_comments: 'Y', params: {})
8
- get("feeds.json?offset=#{offset}&limit=#{limit}&all_comments=#{all_comments}", params: params)
7
+ def get_feeds(offset: 0, limit: 20, all_comments: 'Y', params: {}, unique_user_id: nil)
8
+ get("feeds.json?offset=#{offset}&limit=#{limit}&all_comments=#{all_comments}", params: params, unique_user_id: unique_user_id)
9
9
  end
10
10
  end
11
11
  end
@@ -6,8 +6,8 @@ module MangoApps
6
6
  module CourseCatalog
7
7
  # Get course catalog from MangoApps Learn API
8
8
  # GET /api/v2/learn/course_catalog.json
9
- def get_course_catalog(page: 1, limit: 20, params: {})
10
- get("v2/learn/course_catalog.json?page=#{page}&limit=#{limit}", params: params)
9
+ def get_course_catalog(page: 1, limit: 20, params: {}, unique_user_id: nil)
10
+ get("v2/learn/course_catalog.json?page=#{page}&limit=#{limit}", params: params, unique_user_id: unique_user_id)
11
11
  end
12
12
  end
13
13
  end
@@ -4,8 +4,8 @@ module MangoApps
4
4
  class Client
5
5
  module Learn
6
6
  module CourseDetails
7
- def get_course_details(course_id, params = {})
8
- get("v2/learn/courses/#{course_id}.json", params: params)
7
+ def get_course_details(course_id, params = {}, unique_user_id: nil)
8
+ get("v2/learn/courses/#{course_id}.json", params: params, unique_user_id: unique_user_id)
9
9
  end
10
10
  end
11
11
  end
@@ -4,8 +4,8 @@ module MangoApps
4
4
  class Client
5
5
  module Learn
6
6
  module MyLearning
7
- def get_my_learning(params = {})
8
- get("v2/learn/my_learning.json", params: params)
7
+ def get_my_learning(params = {}, unique_user_id: nil)
8
+ get("v2/learn/my_learning.json", params: params, unique_user_id: unique_user_id)
9
9
  end
10
10
  end
11
11
  end
@@ -4,8 +4,8 @@ module MangoApps
4
4
  class Client
5
5
  module Notifications
6
6
  module MyPriorityItems
7
- def get_my_priority_items(params = {})
8
- get("v2/uac.json", params: params)
7
+ def get_my_priority_items(params = {}, unique_user_id: nil)
8
+ get("v2/uac.json", params: params, unique_user_id: unique_user_id)
9
9
  end
10
10
  end
11
11
  end
@@ -4,8 +4,8 @@ module MangoApps
4
4
  class Client
5
5
  module Posts
6
6
  module GetPostById
7
- def get_post_by_id(post_id, params = {})
8
- get("posts/#{post_id}.json", params: params)
7
+ def get_post_by_id(post_id, params = {}, unique_user_id: nil)
8
+ get("posts/#{post_id}.json", params: params, unique_user_id: unique_user_id)
9
9
  end
10
10
  end
11
11
  end
@@ -4,8 +4,8 @@ module MangoApps
4
4
  class Client
5
5
  module Recognitions
6
6
  module CoreValueTags
7
- def get_core_value_tags(params = {})
8
- get("v2/recognitions/get_core_value_tags.json", params: params)
7
+ def get_core_value_tags(params = {}, unique_user_id: nil)
8
+ get("v2/recognitions/get_core_value_tags.json", params: params, unique_user_id: unique_user_id)
9
9
  end
10
10
  end
11
11
  end
@@ -4,8 +4,8 @@ module MangoApps
4
4
  class Client
5
5
  module Recognitions
6
6
  module GetProfileAwards
7
- def get_profile_awards(params = {})
8
- get("v2/recognitions/get_profile_awards.json", params: params)
7
+ def get_profile_awards(params = {}, unique_user_id: nil)
8
+ get("v2/recognitions/get_profile_awards.json", params: params, unique_user_id: unique_user_id)
9
9
  end
10
10
  end
11
11
  end
@@ -4,8 +4,8 @@ module MangoApps
4
4
  class Client
5
5
  module Recognitions
6
6
  module LeaderboardInfo
7
- def get_leaderboard_info(params = {})
8
- get("v2/recognitions/get_leaderboard_info.json", params: params)
7
+ def get_leaderboard_info(params = {}, unique_user_id: nil)
8
+ get("v2/recognitions/get_leaderboard_info.json", params: params, unique_user_id: unique_user_id)
9
9
  end
10
10
  end
11
11
  end
@@ -4,8 +4,8 @@ module MangoApps
4
4
  class Client
5
5
  module Tasks
6
6
  module GetTaskDetails
7
- def get_task_details(task_id, params = {})
8
- get("tasks/#{task_id}.json", params: params)
7
+ def get_task_details(task_id, params = {}, unique_user_id: nil)
8
+ get("tasks/#{task_id}.json", params: params, unique_user_id: unique_user_id)
9
9
  end
10
10
  end
11
11
  end
@@ -3,8 +3,8 @@
3
3
  module MangoApps
4
4
  class Client
5
5
  module Users
6
- def me(params = {})
7
- get("v2/me.json", params: params)
6
+ def me(params = {}, unique_user_id: nil)
7
+ get("v2/me.json", params: params, unique_user_id: unique_user_id)
8
8
  end
9
9
  end
10
10
  end
@@ -4,8 +4,8 @@ module MangoApps
4
4
  class Client
5
5
  module Wikis
6
6
  module GetWikiDetails
7
- def get_wiki_details(wiki_id, params = {})
8
- get("v2/wikis/#{wiki_id}.json", params: params)
7
+ def get_wiki_details(wiki_id, params = {}, unique_user_id: nil)
8
+ get("v2/wikis/#{wiki_id}.json", params: params, unique_user_id: unique_user_id)
9
9
  end
10
10
  end
11
11
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MangoApps
4
- VERSION = "19.1.1"
4
+ VERSION = "19.1.2"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangoapps-ex-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 19.1.1
4
+ version: 19.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - MangoApps Inc.
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-09-19 00:00:00.000000000 Z
10
+ date: 2025-09-29 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: addressable