Class: GoogleAppsApi::UserProfiles::Api
- Defined in:
- lib/google_apps_api/user_profiles.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#initialize(*args) ⇒ Api
constructor
A new instance of Api.
- #retrieve_all ⇒ Object
- #retrieve_user(user) ⇒ Object
- #set_emails(user, *args) ⇒ Object
Methods inherited from BaseApi
Constructor Details
#initialize(*args) ⇒ Api
Returns a new instance of Api.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/google_apps_api/user_profiles.rb', line 19 def initialize(*args) action_list = { :domain_login => [:post, ':auth:/accounts/ClientLogin' ], :retrieve_all => [:get, ':basic_path:/full?v=3.0'], :retrieve_user => [:get, ':basic_path:/full/'], :set_emails => [:put, ':basic_path:/full/'], :next => [:get, '' ] } = args. domain = [:domain] .merge!(:action_hash => action_list, :auth => "https://www.google.com", :feed => "https://www.google.com", :service => "cp") [:basic_path] = [:feed] + "/m8/feeds/profiles/domain/#{[:domain]}" super() end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
17 18 19 |
# File 'lib/google_apps_api/user_profiles.rb', line 17 def token @token end |
Instance Method Details
#retrieve_all ⇒ Object
39 40 41 42 |
# File 'lib/google_apps_api/user_profiles.rb', line 39 def retrieve_all() response = request(:retrieve_all) return response.to_s end |
#retrieve_user(user) ⇒ Object
44 45 46 47 |
# File 'lib/google_apps_api/user_profiles.rb', line 44 def retrieve_user(user) response = request(:retrieve_user, :query => user + "?v=3.0") return response.to_s end |
#set_emails(user, *args) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/google_apps_api/user_profiles.rb', line 49 def set_emails(user, *args) emails = args. doc = Document.new(retrieve_user(user).to_s) doc.elements.each("entry/gd:email") do |e| e.parent.delete(e) end primary = emails.delete(:primary) || :other base = doc.elements["entry"] emails.each_pair do |loc, email| base.add_element("gd:email", "address" => email, "rel" => "http://schemas.google.com/g/2005##{loc.to_s}", "primary" => loc == primary ? "true" : "false") end response = request(:set_emails,:query => user + "?v=3.0", :body => doc.to_s) end |