Commit b93f9ab7 authored by Jose Ernesto Suarez's avatar Jose Ernesto Suarez

Fix propossal for allow using the sandbox

parent 870d6b52
.DS_Store
zoholib*.gem
.env
example_id | status | run_time |
----------------------------- | ------ | --------------- |
./spec/zoholib_spec.rb[1:1] | passed | 0.00155 seconds |
./spec/zoholib_spec.rb[1:2] | passed | 0.00156 seconds |
./spec/zoholib_spec.rb[1:3:1] | passed | 0.00096 seconds |
./spec/zoholib_spec.rb[1:3:2] | passed | 0.00039 seconds |
./spec/zoholib_spec.rb[1:3:3] | passed | 0.00039 seconds |
./spec/zoholib_spec.rb[1:3:4] | passed | 0.00029 seconds |
./spec/zoholib_spec.rb[1:3:5] | passed | 0.00045 seconds |
./spec/zoholib_spec.rb[1:1] | passed | 0.00071 seconds |
./spec/zoholib_spec.rb[1:2] | passed | 0.00047 seconds |
./spec/zoholib_spec.rb[1:3:1] | passed | 0.00044 seconds |
./spec/zoholib_spec.rb[1:3:2] | passed | 0.00006 seconds |
./spec/zoholib_spec.rb[1:3:3] | passed | 0.00006 seconds |
./spec/zoholib_spec.rb[1:3:4] | passed | 0.00004 seconds |
./spec/zoholib_spec.rb[1:3:5] | passed | 0.00004 seconds |
PATH
remote: .
specs:
zoholib (0.0.5b)
zoholib (0.22)
http (~> 4.4.0)
httparty (~> 0.18.0)
launchy (~> 2.5.0)
logger (~> 1.4.2)
savon (~> 2.12.0)
savon (~> 2.12.1)
wasabi (= 3.5.0)
GEM
remote: https://rubygems.org/
......@@ -69,7 +70,7 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.2)
savon (2.12.0)
savon (2.12.1)
akami (~> 1.2)
builder (>= 2.1.2)
gyoku (~> 1.2)
......@@ -96,7 +97,8 @@ DEPENDENCIES
logger (~> 1.4.2)
rake (~> 13.0.1)
rspec (~> 3.0)
savon (~> 2.12.0)
savon (~> 2.12.1)
wasabi (= 3.5.0)
zoholib!
BUNDLED WITH
......
# Zoho Library
\ No newline at end of file
# Zoho Library
In case a new refresh_token is requested, is needed to generate it executing by hand a new authorization request.
This is becausee the ZOHO API opens a browser for manage the authorization, this can't be managed in the background
The AuthorizationRequest class also opens a server for receive the callback with the information.
```
irb> require './zoholib'
irb> options = {:client_id => '1000.W3UX1B57UxxxxxxxxxxxxxMDH',
:client_secret => '9axxxxxxxxxxxxxxdb3d18e',
:scope => "ZohoCRM.modules.ALL,ZohoCRM.coql.read",
:environment => "sandbox"}
irb> z=Wedoops::Zoholib::AuthorizationRequest.new(options)
irb> z.authorize
```
with this result
D, [2020-11-25T18:54:29.342094 #15899] DEBUG -- : grant token auth: {:environment=>"sandbox", :query=>{:client_id=>"1000.W3UX1B57UxxxxxxxxxxxxxMDH", :client_secret=>"9axxxxxxxxxxxxxxdb3d18e", :scope=>"ZohoCRM.modules.ALL,ZohoCRM.coql.read", :response_type=>"code", :access_type=>"offline", :redirect_uri=>"http://localhost:8000/auth/callback"}, :follow_redirects=>false} response
I, [2020-11-25T18:54:29.348050 #15899] INFO -- : Reading socket response
I, [2020-11-25T18:54:44.036801 #15899] INFO -- : GRANT TOKEN: 1000.70fec5d6a4dd2375df96616613d8205e.45603cb37cbd32987edb80d9a48dd38e
I, [2020-11-25T18:54:44.746596 #15899] INFO -- : [HTTParty] [2020-11-25 18:54:44 +0200] 200 "POST /token" 258
D, [2020-11-25T18:54:44.746711 #15899] DEBUG -- : grant request:{:query=>{:client_id=>"1000.W3UX1B57UxxxxxxxxxxxxxMDH", :client_secret=>"9axxxxxxxxxxxxxxdb3d18e", :redirect_uri=>"http://localhost:8000/auth/callback", :code=>"1000.70fec5d6a4dd2375df96616613d8205e.45603cb37cbd32987edb80d9a48dd38e", :grant_type=>"authorization_code"}, :logger=>#<Logger:0x00007f8e261545d0 @level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x00007f8e26154558 @datetime_format=nil>, @formatter=nil, @logdev=#<Logger::LogDevice:0x00007f8e261544e0 @shift_period_suffix=nil, @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x00007f8e26154490>>>} response: {"access_token":"1000.64686e79ebcd77a364bd28b906139d1b.453935f30b299d09087a2b2731543468","refresh_token":"1000.5c516d9e6caf86906bf7249101bxxxxxxxxxxxxxxxx380","api_domain":"https://www.zohoapis.com","token_type":"Bearer","expires_in":3600}
=> {:access_token=>"1000.64686e79ebcd7xxxxxxxxxb.453935f30b299d0908xxxxxxxxx8", :refresh_token=>"1000.5c516d9e6caf86906bf7249101bxxxxxxxxxxxxxxxx380", :api_domain=>"https://www.zohoapis.com", :token_type=>"Bearer", :expires_in=>3600}
now, we are able to initialize a new client with this token for accesing the sandbox
o={:refresh_token=>"1000.5c516d9e6caf86906bf7249101bxxxxxxxxxxxxxxxx380",
2.5.1 :009 > :client_id => '1000.W3UX1B57UxxxxxxxxxxxxxMDH',
2.5.1 :010 > :client_secret => '9axxxxxxxxxxxxxxdb3d18e',
2.5.1 :011 > :scope => "ZohoCRM.modules.ALL,ZohoCRM.coql.read",
2.5.1 :012 > :environment => "sandbox"}
z=Wedoops::Zoholib::ZohoBasicClient.new(o)
z.read("Contacts/4230509000000362013")
D, [2020-11-25T19:00:25.465606 #15899] DEBUG -- : Token is still valid
{"data"=>
[{"Owner"=>
{"name"=>"Zoho Admin",
"id"=>"4230509000000297001",
"email"=>"zoho.admin.ext@adamo.es"},
"Gis_Area"=>nil,
"B2B_Lead_Size"=>nil,
"Direcci_n_Cadmin"=>nil,
"$state"=>"save",
"$process_flow"=>false,
"Street"=>nil,
"id"=>"4230509000000362013",
"Coverage_Search_String"=>nil,
"$approval"=>
{"delegate"=>false, "approve"=>false, "reject"=>false, "resubmit"=>false},
"First_Visited_URL"=>nil,
"Created_Time"=>"2020-11-17T14:34:50+01:00",
"Estado_en_Cadmin"=>nil,
"response_B12"=>nil,
"Permanencia"=>nil,
"Longitude"=>nil,
"Nearest_Coverage"=>nil,
"Offline_Sent_Date"=>nil,
"Que_tiene_contratado"=>nil,
"Adamo_score"=>nil,
"Partner1"=>nil,
"LinkedIn"=>nil,
"Offline_Campaign"=>nil,
"Customer_ID"=>nil,
"Campa_a"=>nil,
"Last_Visited_Time"=>nil,
"Created_By"=>
{"name"=>"Zoho Admin",
"id"=>"4230509000000297001",
"email"=>"zoho.admin.ext@adamo.es"},
"UTM_Medium"=>nil,
"Description"=>nil,
"Customer_status"=>"WebSearch",
"Number_Of_Chats"=>nil,
"Vive_en_Poblaci_n"=>false,
"$review_process"=>{"approve"=>false, "reject"=>false, "resubmit"=>false},
"Average_Time_Spent_Minutes"=>nil,
"Salutation"=>nil,
"Full_Name"=>"Bo Bonnevie",
"RESPUESTA_IMP1"=>nil,
"Account_Name"=>nil,
"Email_Opt_Out"=>false,
"Tipo_accion"=>[],
"Last_Resoluci_n"=>nil,
"Fecha_Evento"=>nil,
"SMS_Campaign"=>nil,
"Mobile"=>nil,
"Territories"=>nil,
"smsmagic4__LeadIdCPY"=>nil,
"smsmagic4__Plain_Phone"=>"638737344",
"Form_URL"=>nil,
"Event_ID"=>nil,
"$orchestration"=>nil,
"Layout"=>{"name"=>"B2C", "id"=>"4230509000000091033"},
"Lead_Source"=>nil,
"CMS_Token"=>nil,
"Tag"=>[],
"Conoze_Adamo_por"=>nil,
"Email"=>"bo.bonnevie.ext@adamo.es",
"$currency_symbol"=>"EUR",
"Cargo_en_la_empresa"=>nil,
"Visitor_Score"=>nil,
"CallType_Sys02"=>nil,
"Latitude"=>nil,
"Accion"=>[],
"Last_Activity_Time"=>nil,
"Unsubscribed_Mode"=>nil,
"Adamo_Address"=>nil,
"Mailing_Date"=>nil,
"Zip_Code"=>nil,
"$approved"=>true,
"Reporting_To"=>nil,
"Not_For_Telesale"=>false,
"Fecha_de_carga"=>nil,
"Days_Visited"=>nil,
"Enlace_Cadmin"=>nil,
"Channel"=>nil,
"$editable"=>true,
"City"=>nil,
"Province"=>nil,
"Full_street"=>nil,
"Matching_Adamo_Appartment"=>nil,
"Lead_Created_Date"=>"2020-11-17T14:00:00+01:00",
"Previous_Distance"=>nil,
"Campaign"=>nil,
"UTM_Content"=>nil,
"ValidPhone"=>false,
"Embajador_Fiberhood"=>false,
"Operator"=>"Marketing",
"UTM_Campaign"=>nil,
"Poblaci_n_Evento"=>nil,
"First_Name"=>"Bo",
"Modified_By"=>
{"name"=>"Zoho Admin",
"id"=>"4230509000000297001",
"email"=>"zoho.admin.ext@adamo.es"},
"$review"=>nil,
"Phone"=>"638737344",
"Adamo_internal_ID"=>"NA",
"Modified_Time"=>"2020-11-17T14:34:50+01:00",
"Distance_nearest_Coverage"=>nil,
"Unsubscribed_Time"=>nil,
"Fiberhood"=>nil,
"First_Visited_Time"=>nil,
"Sabe_de_adamo"=>false,
"Last_Name"=>"Bonnevie",
"$in_merge"=>false,
"Referrer"=>nil,
"Distance_Updated"=>nil,
"UTM_Source"=>nil,
"$approval_state"=>"approved",
"SMS_Sent_Date"=>nil,
"DNI"=>nil}]}
\ No newline at end of file
......@@ -20,7 +20,7 @@ module Wedoops
@options = Hash.new
# environment specific settings
if options.has_key?(:environment) && options[:environment] == "sandbox"
self.class.base_uri "https://sandbox.zohoapis.eu/oauth/v2/"
self.class.base_uri "https://accounts.zoho.com/oauth/v2/"
options.delete(:environment)
@options[:environment] = "sandbox"
end
......
......@@ -7,7 +7,7 @@ module Wedoops
#headers: {"Authorization" => "Token token=\"111\""}
def initialize(options={})
if options.has_key?(:environment) && options[:environment] == "sandbox"
self.class.base_uri "https://sandbox.zohoapis.eu/oauth/v2/"
self.class.base_uri "https://accounts.zoho.com/oauth/v2/"
options.delete(:environment)
end
......
......@@ -15,7 +15,7 @@ module Wedoops
def initialize(options={})
# environment specific settings
if options.has_key?(:environment) && options[:environment] == "sandbox"
self.class.base_uri "https://sandbox.zohoapis.eu/oauth/v2/"
self.class.base_uri "https://accounts.zoho.com/oauth/v2/"
options.delete(:environment)
end
......
# frozen_string_literal: true
module Wedoops
module Zoholib
VERSION = '0.22'
VERSION = '0.23'
end
end
\ No newline at end of file
......@@ -16,7 +16,7 @@ module Wedoops
def initialize(options={})
# environment specific settings
if options.has_key?(:environment) && options[:environment] == "sandbox"
self.class.base_uri "https://sandbox.zohoapis.eu/crm/v2/"
self.class.base_uri "https://sandbox.zohoapis.com/crm/v2/"
end
#Es un cliennte basico que trabaja a partir de refresh_tokens
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment