zoho_tools 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/changelog.md +5 -0
- data/lib/zoho_tools/mock/spec_helper.rb +68 -7
- data/lib/zoho_tools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d280f463100cf8c240ab86eb6e54868bae66e91c2c5bd8b1588feb4fe616a89b
|
4
|
+
data.tar.gz: 8924fa85c00149171acb824f8284671872a279df816416b43f4ae974da9ebf49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17754b8ee90114efb551eef5b77e6471c6831efd59aa319a9c1fc362b0c0f5f6ab0aaf2803969ff01fb4fd3b863ae032576849beb5326bc1acc770253cd66161
|
7
|
+
data.tar.gz: 5507afc6b38702d4329327a4b14ca2a1bfc74701985c4530cf5c85250d2f037c3261e20c8755008aad9e6febb7005490a86c176f23f4e132b997c1118618f904
|
data/Gemfile.lock
CHANGED
data/changelog.md
CHANGED
@@ -1,18 +1,79 @@
|
|
1
|
+
require 'webmock/rspec'
|
2
|
+
|
1
3
|
module ZohoTools
|
2
4
|
module SpecHelper
|
3
5
|
class Interface
|
4
|
-
|
6
|
+
include RSpec::Mocks::ExampleMethods
|
7
|
+
include WebMock::API
|
8
|
+
|
9
|
+
def stub_authorize_code(code, access_token:, refresh_token:, success: true)
|
10
|
+
response_body = if success
|
11
|
+
{ access_token: access_token,
|
12
|
+
refresh_token: refresh_token,
|
13
|
+
scope: 'ZohoCampaigns.campaign.ALL ZohoCampaigns.contact.ALL',
|
14
|
+
api_domain: 'https://www.zohoapis.eu',
|
15
|
+
token_type: 'Bearer',
|
16
|
+
expires_in: 3600 }
|
17
|
+
else
|
18
|
+
{ error: 'Invalid code' }
|
19
|
+
end
|
20
|
+
stub_request(:post, URI.join(ZohoTools.config.accounts_api_url, '/oauth/v2/token'))
|
21
|
+
.with(body: hash_including(client_id: ZohoTools.config.client_id,
|
22
|
+
client_secret: ZohoTools.config.client_secret,
|
23
|
+
code: code,
|
24
|
+
grant_type: 'authorization_code',
|
25
|
+
redirect_uri: ZohoTools.config.callback_url))
|
26
|
+
.to_return(status: 200, body: response_body.to_json)
|
27
|
+
end
|
28
|
+
|
29
|
+
def stub_refresh_access_tokens(refresh_token, access_token:, success: true)
|
30
|
+
response_body = if success
|
31
|
+
{ access_token: access_token,
|
32
|
+
scope: 'ZohoCampaigns.campaign.ALL ZohoCampaigns.contact.ALL',
|
33
|
+
api_domain: 'https://www.zohoapis.eu',
|
34
|
+
token_type: 'Bearer',
|
35
|
+
expires_in: 3600 }
|
36
|
+
else
|
37
|
+
{ error: 'Invalid refresh token' }
|
38
|
+
end
|
5
39
|
stub_request(:post, URI.join(ZohoTools.config.accounts_api_url, '/oauth/v2/token'))
|
6
40
|
.with(body: hash_including(client_id: ZohoTools.config.client_id,
|
7
41
|
client_secret: ZohoTools.config.client_secret,
|
8
42
|
refresh_token: refresh_token,
|
9
43
|
grant_type: 'refresh_token'))
|
10
|
-
.to_return(status: 200,
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
44
|
+
.to_return(status: 200, body: response_body.to_json)
|
45
|
+
end
|
46
|
+
|
47
|
+
def stub_list_subscribe(access_token:, list_key:, contact_info:, source:, success: true)
|
48
|
+
response_body = if success
|
49
|
+
{ status: 'success',
|
50
|
+
message: 'A confirmation email is sent to the user. User needs to confirm to successfully subscribe.' }
|
51
|
+
else
|
52
|
+
{ error: 'Invalid code' }
|
53
|
+
end
|
54
|
+
|
55
|
+
stub_request(:post, URI.join(ZohoTools.config.campaigns_api_url, '/api/v1.1/json/listsubscribe'))
|
56
|
+
.with(body: hash_including(listkey: list_key,
|
57
|
+
resfmt: 'JSON',
|
58
|
+
contactinfo: contact_info.is_a?(RSpec::Mocks::ArgumentMatchers::SingletonMatcher) ? contact_info : contact_info.to_json,
|
59
|
+
source: source),
|
60
|
+
headers: { 'Authorization' => "Zoho-oauthtoken #{access_token}" })
|
61
|
+
.to_return(status: 200, body: response_body.to_json)
|
62
|
+
end
|
63
|
+
|
64
|
+
def stub_list_unsubscribe(access_token:, list_key:, contact_info:, success: true)
|
65
|
+
response_body = if success
|
66
|
+
{ status: 'success', message: 'User successfully unsubscribed.' }
|
67
|
+
else
|
68
|
+
{ error: 'Invalid code' }
|
69
|
+
end
|
70
|
+
|
71
|
+
stub_request(:post, URI.join(ZohoTools.config.campaigns_api_url, '/api/v1.1/json/listunsubscribe'))
|
72
|
+
.with(body: hash_including(listkey: list_key,
|
73
|
+
resfmt: 'JSON',
|
74
|
+
contactinfo: contact_info.to_json),
|
75
|
+
headers: { 'Authorization' => "Zoho-oauthtoken #{access_token}" })
|
76
|
+
.to_return(status: 200, body: response_body.to_json)
|
16
77
|
end
|
17
78
|
end
|
18
79
|
|
data/lib/zoho_tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zoho_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lubomir Vnenk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|