Class: Rails::Contact::Google::Client
- Inherits:
-
Object
- Object
- Rails::Contact::Google::Client
- Defined in:
- lib/rails/contact/google/client.rb
Constant Summary collapse
- PEOPLE_API_BASE =
"https://people.googleapis.com/v1".freeze
Instance Method Summary collapse
- #create_contact(payload) ⇒ Object
- #delete_contact(resource_name) ⇒ Object
-
#initialize(access_token:) ⇒ Client
constructor
A new instance of Client.
- #update_contact(resource_name, payload) ⇒ Object
Constructor Details
#initialize(access_token:) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 |
# File 'lib/rails/contact/google/client.rb', line 9 def initialize(access_token:) @connection = Faraday.new(url: PEOPLE_API_BASE) do |faraday| faraday.request :retry, max: 3, interval: 0.5, backoff_factor: 2 faraday.response :raise_error end @access_token = access_token end |
Instance Method Details
#create_contact(payload) ⇒ Object
17 18 19 |
# File 'lib/rails/contact/google/client.rb', line 17 def create_contact(payload) post("/people:createContact", payload) end |
#delete_contact(resource_name) ⇒ Object
25 26 27 |
# File 'lib/rails/contact/google/client.rb', line 25 def delete_contact(resource_name) @connection.delete("/#{resource_name}") { |request| request.headers = headers } end |
#update_contact(resource_name, payload) ⇒ Object
21 22 23 |
# File 'lib/rails/contact/google/client.rb', line 21 def update_contact(resource_name, payload) patch("/#{resource_name}:updateContact", payload) end |