-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Sync Term data to API server by POST/PUT/DELETE method, #151
- Request to original API with HTTP POST/PUT/DELETE method for Term resource
- Loading branch information
1 parent
97d203c
commit 6517268
Showing
9 changed files
with
97 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'rest-client' | ||
require 'json' | ||
|
||
module RosterApi | ||
extend ActiveSupport::Concern | ||
|
||
private | ||
|
||
def request_roster_api(endpoint, method, payload={}) | ||
url = Rails.application.secrets.roster_url_prefix + endpoint | ||
# FIXME: verify_ssl should be true! | ||
request_hash = { | ||
url: url, | ||
method: method, | ||
headers: {Authorization: 'Bearer ' + Rails.application.secrets.roster_token}, | ||
verify_ssl: false | ||
} | ||
request_hash.merge!({payload: payload}) if payload.present? | ||
response = RestClient::Request.execute(request_hash) | ||
JSON.parse(response.body) if response.body.present? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters