Created
June 3, 2018 07:48
-
-
Save dsignr/f5c6469c6e4a419862b6a19a9a886268 to your computer and use it in GitHub Desktop.
Ruby syntax example
This file contains hidden or 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
class DriveAPI | |
include HTTParty | |
base_uri 'https://www.googleapis.com' | |
#for debugging | |
debug_output $stdout | |
end | |
def create_file(file_name, parent_id) | |
check_token! | |
access_token = current_user.access_token | |
response = DriveAPI.post( | |
'/drive/v3/files', | |
:body => { "mimeType"=> "application/vnd.google-apps.document", | |
"name"=> "#{file_name}", | |
"parents"=> ["#{parent_id}"] | |
}.to_json, | |
:headers => { | |
"Authorization" => "Bearer #{access_token}", | |
"Content-Type" => "application/json" | |
} | |
) | |
response | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment