Class: OmniGroupContacts::Importer::Gmailgroup
- Inherits:
-
Middleware::OAuth2
- Object
- Middleware::BaseOAuth
- Middleware::OAuth2
- OmniGroupContacts::Importer::Gmailgroup
- Includes:
- ParseUtils
- Defined in:
- lib/omnigroupcontacts/importer/gmailgroup.rb
Constant Summary
Constants included from HTTPUtils
Instance Attribute Summary collapse
-
#auth_host ⇒ Object
readonly
Returns the value of attribute auth_host.
-
#auth_token_path ⇒ Object
readonly
Returns the value of attribute auth_token_path.
-
#authorize_path ⇒ Object
readonly
Returns the value of attribute authorize_path.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Attributes inherited from Middleware::OAuth2
#client_id, #client_secret, #redirect_path
Attributes inherited from Middleware::BaseOAuth
Instance Method Summary collapse
- #fetch_contacts_using_access_token(access_token, token_type, group_id) ⇒ Object
- #fetch_current_user(access_token, token_type) ⇒ Object
- #fetch_groups_using_access_token(access_token, token_type) ⇒ Object
-
#initialize(*args) ⇒ Gmailgroup
constructor
A new instance of Gmailgroup.
Methods included from ParseUtils
#birthday_format, #email_to_name, #full_name, #image_url_from_email, #normalize_name
Methods inherited from Middleware::OAuth2
#fetch_group_contacts, #fetch_groups, #redirect_uri, #refresh_token_prop_name, #request_authorization_from_user
Methods included from Authorization::OAuth2
#authorization_url, #fetch_access_token, #refresh_access_token
Methods included from HTTPUtils
encode, host_url_from_rack_env, query_string_to_map, scheme, to_query_string
Methods inherited from Middleware::BaseOAuth
Constructor Details
#initialize(*args) ⇒ Gmailgroup
Returns a new instance of Gmailgroup.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/omnigroupcontacts/importer/gmailgroup.rb', line 11 def initialize *args super *args @auth_host = "accounts.google.com" @authorize_path = "/o/oauth2/auth" @auth_token_path = "/o/oauth2/token" @scope = (args[3] && args[3][:scope]) || "https://www.google.com/m8/feeds https://www.googleapis.com/auth/userinfo#email https://www.googleapis.com/auth/userinfo.profile" @contacts_host = "www.google.com" @contacts_path = "/m8/feeds/groups/default/full" @max_results = (args[3] && args[3][:max_results]) || 100 @self_host = "www.googleapis.com" @profile_path = "/oauth2/v1/userinfo" end |
Instance Attribute Details
#auth_host ⇒ Object (readonly)
Returns the value of attribute auth_host.
9 10 11 |
# File 'lib/omnigroupcontacts/importer/gmailgroup.rb', line 9 def auth_host @auth_host end |
#auth_token_path ⇒ Object (readonly)
Returns the value of attribute auth_token_path.
9 10 11 |
# File 'lib/omnigroupcontacts/importer/gmailgroup.rb', line 9 def auth_token_path @auth_token_path end |
#authorize_path ⇒ Object (readonly)
Returns the value of attribute authorize_path.
9 10 11 |
# File 'lib/omnigroupcontacts/importer/gmailgroup.rb', line 9 def @authorize_path end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
9 10 11 |
# File 'lib/omnigroupcontacts/importer/gmailgroup.rb', line 9 def scope @scope end |
Instance Method Details
#fetch_contacts_using_access_token(access_token, token_type, group_id) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/omnigroupcontacts/importer/gmailgroup.rb', line 30 def fetch_contacts_using_access_token access_token, token_type, group_id fetch_current_user(access_token, token_type) @contacts_path = "/m8/feeds/contacts/default/full?&group=#{group_id}" contacts_response = https_get(@contacts_host, @contacts_path, contacts_req_params, contacts_req_headers(access_token, token_type)) contacts_from_response contacts_response end |
#fetch_current_user(access_token, token_type) ⇒ Object
37 38 39 40 41 |
# File 'lib/omnigroupcontacts/importer/gmailgroup.rb', line 37 def fetch_current_user access_token, token_type self_response = https_get(@self_host, @profile_path, contacts_req_params, contacts_req_headers(access_token, token_type)) user = current_user(self_response, access_token, token_type) set_current_user user end |
#fetch_groups_using_access_token(access_token, token_type) ⇒ Object
24 25 26 27 28 |
# File 'lib/omnigroupcontacts/importer/gmailgroup.rb', line 24 def fetch_groups_using_access_token access_token, token_type fetch_current_user(access_token, token_type) groups_response = https_get(@contacts_host, @contacts_path, contacts_req_params, contacts_req_headers(access_token, token_type)) groups_from_response groups_response end |