Class: MangoApps::Client
- Inherits:
-
Object
- Object
- MangoApps::Client
- Includes:
- Attachments, Feeds, Learn, Libraries, Notifications, Posts, Recognitions, Tasks, Trackers, Users, Wikis
- Defined in:
- lib/mangoapps/client.rb,
lib/mangoapps/modules/feeds.rb,
lib/mangoapps/modules/learn.rb,
lib/mangoapps/modules/posts.rb,
lib/mangoapps/modules/tasks.rb,
lib/mangoapps/modules/users.rb,
lib/mangoapps/modules/wikis.rb,
lib/mangoapps/modules/trackers.rb,
lib/mangoapps/modules/libraries.rb,
lib/mangoapps/modules/attachments.rb,
lib/mangoapps/modules/feeds/feeds.rb,
lib/mangoapps/modules/recognitions.rb,
lib/mangoapps/modules/notifications.rb,
lib/mangoapps/modules/tasks/get_tasks.rb,
lib/mangoapps/modules/wikis/get_wikis.rb,
lib/mangoapps/modules/learn/my_learning.rb,
lib/mangoapps/modules/posts/get_all_posts.rb,
lib/mangoapps/modules/learn/course_catalog.rb,
lib/mangoapps/modules/learn/course_details.rb,
lib/mangoapps/modules/posts/get_post_by_id.rb,
lib/mangoapps/modules/trackers/get_trackers.rb,
lib/mangoapps/modules/tasks/get_task_details.rb,
lib/mangoapps/modules/wikis/get_wiki_details.rb,
lib/mangoapps/modules/attachments/get_folders.rb,
lib/mangoapps/modules/learn/course_categories.rb,
lib/mangoapps/modules/libraries/get_libraries.rb,
lib/mangoapps/modules/recognitions/gift_cards.rb,
lib/mangoapps/modules/libraries/get_library_items.rb,
lib/mangoapps/modules/notifications/notifications.rb,
lib/mangoapps/modules/attachments/get_folder_files.rb,
lib/mangoapps/modules/recognitions/core_value_tags.rb,
lib/mangoapps/modules/recognitions/get_award_feeds.rb,
lib/mangoapps/modules/recognitions/get_awards_list.rb,
lib/mangoapps/modules/recognitions/get_team_awards.rb,
lib/mangoapps/modules/recognitions/award_categories.rb,
lib/mangoapps/modules/recognitions/leaderboard_info.rb,
lib/mangoapps/modules/notifications/my_priority_items.rb,
lib/mangoapps/modules/recognitions/get_profile_awards.rb,
lib/mangoapps/modules/libraries/get_library_categories.rb
Defined Under Namespace
Modules: Attachments, Feeds, Learn, Libraries, Notifications, Posts, Recognitions, Tasks, Trackers, Users, Wikis
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#oauth ⇒ Object
readonly
Returns the value of attribute oauth.
Instance Method Summary collapse
-
#access_token ⇒ Object
—- Authentication —-.
- #authenticate!(authorization_code:, code_verifier: nil) ⇒ Object
- #authenticated? ⇒ Boolean
-
#authorization_url(state:, code_challenge: nil, code_challenge_method: "S256", **extra_params) ⇒ Object
—- OAuth Helpers —-.
- #delete(path, headers: {}) ⇒ Object
-
#get(path, params: {}, headers: {}) ⇒ Object
—- HTTP Methods —-.
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #post(path, body: nil, headers: {}) ⇒ Object
- #put(path, body: nil, headers: {}) ⇒ Object
- #refresh_token! ⇒ Object
Methods included from Wikis::GetWikiDetails
Methods included from Wikis::GetWikis
Methods included from Tasks::GetTaskDetails
Methods included from Tasks::GetTasks
Methods included from Attachments::GetFolderFiles
Methods included from Attachments::GetFolders
Methods included from Trackers::GetTrackers
Methods included from Libraries::GetLibraryItems
Methods included from Libraries::GetLibraryCategories
Methods included from Libraries::GetLibraries
Methods included from Posts::GetPostById
Methods included from Posts::GetAllPosts
Methods included from Feeds::Feeds
Methods included from Notifications::Notifications
Methods included from Notifications::MyPriorityItems
Methods included from Recognitions::GetAwardFeeds
Methods included from Recognitions::GetTeamAwards
Methods included from Recognitions::GetProfileAwards
Methods included from Recognitions::GetAwardsList
Methods included from Recognitions::GiftCards
Methods included from Recognitions::LeaderboardInfo
Methods included from Recognitions::CoreValueTags
Methods included from Recognitions::AwardCategories
Methods included from Users
Methods included from Learn::MyLearning
Methods included from Learn::CourseDetails
Methods included from Learn::CourseCategories
Methods included from Learn::CourseCatalog
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/mangoapps/client.rb', line 10 def config @config end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
10 11 12 |
# File 'lib/mangoapps/client.rb', line 10 def http @http end |
#oauth ⇒ Object (readonly)
Returns the value of attribute oauth.
10 11 12 |
# File 'lib/mangoapps/client.rb', line 10 def oauth @oauth end |
Instance Method Details
#access_token ⇒ Object
—- Authentication —-
19 20 21 |
# File 'lib/mangoapps/client.rb', line 19 def access_token @access_token ||= load_access_token end |
#authenticate!(authorization_code:, code_verifier: nil) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/mangoapps/client.rb', line 27 def authenticate!(authorization_code:, code_verifier: nil) @access_token = oauth.get_token( authorization_code: , code_verifier: code_verifier ) end |
#authenticated? ⇒ Boolean
23 24 25 |
# File 'lib/mangoapps/client.rb', line 23 def authenticated? access_token && !token_expired? end |
#authorization_url(state:, code_challenge: nil, code_challenge_method: "S256", **extra_params) ⇒ Object
—- OAuth Helpers —-
58 59 60 61 62 63 64 65 |
# File 'lib/mangoapps/client.rb', line 58 def (state:, code_challenge: nil, code_challenge_method: "S256", **extra_params) oauth.( state: state, code_challenge: code_challenge, code_challenge_method: code_challenge_method, extra_params: extra_params ) end |
#delete(path, headers: {}) ⇒ Object
53 54 55 |
# File 'lib/mangoapps/client.rb', line 53 def delete(path, headers: {}) request(:delete, path, headers: headers) end |
#get(path, params: {}, headers: {}) ⇒ Object
—- HTTP Methods —-
41 42 43 |
# File 'lib/mangoapps/client.rb', line 41 def get(path, params: {}, headers: {}) request(:get, path, params: params, headers: headers) end |
#post(path, body: nil, headers: {}) ⇒ Object
45 46 47 |
# File 'lib/mangoapps/client.rb', line 45 def post(path, body: nil, headers: {}) request(:post, path, body: body, headers: headers) end |
#put(path, body: nil, headers: {}) ⇒ Object
49 50 51 |
# File 'lib/mangoapps/client.rb', line 49 def put(path, body: nil, headers: {}) request(:put, path, body: body, headers: headers) end |
#refresh_token! ⇒ Object
34 35 36 37 38 |
# File 'lib/mangoapps/client.rb', line 34 def refresh_token! raise MangoApps::TokenExpiredError, "No refresh token available" unless access_token&.refresh_token @access_token = oauth.refresh!(access_token) end |