rdstation-ruby-client 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -0
- data/lib/rdstation-ruby-client.rb +1 -0
- data/lib/rdstation/authentication.rb +54 -0
- data/lib/rdstation/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49d611a1dd83c95db29c6fd6abaf5e174d0cfaab
|
4
|
+
data.tar.gz: 47644e5e101c69feeacd833935dae34764a915e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9d6ddc90bab5f0ba6a9403a10f4cd6efad29f31c2998f2ea1cbac80996caf1e97bcccc6c59a27a3723c311ba505b7f4fef3f45685fe7fd1d99115b64736731f
|
7
|
+
data.tar.gz: 628b0e48df49f7082784d6a84e4d6a31590237f9140198bed8206d7e1a12c545f87dfcb0512f418af785735b10719fee8f4736391ad4ffebdf6a5c2d5827b975
|
data/README.md
CHANGED
@@ -47,6 +47,33 @@ rdstation_client = RDStation::Client.new('rdstation_token', 'auth_token')
|
|
47
47
|
rdstation_client.change_lead_status(email: 'joe@foo.bar', status: 'won', value: 999)
|
48
48
|
```
|
49
49
|
|
50
|
+
### Authentication
|
51
|
+
|
52
|
+
#### Getting authentication URL
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
rdstation_authentication = RDStation::Authentication.new('client_id', 'client_secret')
|
56
|
+
|
57
|
+
redirect_url = 'https://yourapp.org/auth/callback'
|
58
|
+
rdstation_authentication.auth_url(redirect_url)
|
59
|
+
```
|
60
|
+
|
61
|
+
#### Getting access_token
|
62
|
+
|
63
|
+
You will need the code param that is returned from RD Station to your application after the user confirms the access at the authorization dialog.
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
rdstation_authentication = RDStation::Authentication.new('client_id', 'client_secret')
|
67
|
+
rdstation_authentication.authenticate(code_returned_from_rdstation)
|
68
|
+
```
|
69
|
+
|
70
|
+
#### Updating access_token
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
rdstation_authentication = RDStation::Authentication.new('client_id', 'client_secret')
|
74
|
+
rdstation_authentication.update_access_token('refresh_token')
|
75
|
+
```
|
76
|
+
|
50
77
|
### Contacts
|
51
78
|
|
52
79
|
#### Getting a Contact by UUID
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module RDStation
|
3
|
+
class Authentication
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
def initialize(client_id, client_secret)
|
7
|
+
@client_id = client_id
|
8
|
+
@client_secret = client_secret
|
9
|
+
end
|
10
|
+
|
11
|
+
#
|
12
|
+
# param redirect_url
|
13
|
+
# URL that the user will be redirected
|
14
|
+
# after confirming application authorization
|
15
|
+
#
|
16
|
+
def auth_url(redirect_url)
|
17
|
+
"https://api.rd.services/auth/dialog?client_id=#{@client_id}&redirect_url=#{redirect_url}"
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# param code
|
22
|
+
# parameter sent by RDStation after user confirms authorization
|
23
|
+
#
|
24
|
+
def authenticate(code)
|
25
|
+
post_to_auth_endpoint({ :code => code })
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# param refresh_token
|
30
|
+
# parameter sent by RDStation after authenticate
|
31
|
+
#
|
32
|
+
def update_access_token(refresh_token)
|
33
|
+
post_to_auth_endpoint({ :refresh_token => refresh_token })
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def auth_token_url
|
39
|
+
"https://api.rd.services/auth/token"
|
40
|
+
end
|
41
|
+
|
42
|
+
def post_to_auth_endpoint(params)
|
43
|
+
default_body = { :client_id => @client_id, :client_secret => @client_secret }
|
44
|
+
|
45
|
+
self.class.post(
|
46
|
+
auth_token_url,
|
47
|
+
:headers => {
|
48
|
+
"Accept-Encoding": "identity"
|
49
|
+
},
|
50
|
+
:body => default_body.merge(params)
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/rdstation/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdstation-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo L F Casaretto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- README.md
|
123
123
|
- Rakefile
|
124
124
|
- lib/rdstation-ruby-client.rb
|
125
|
+
- lib/rdstation/authentication.rb
|
125
126
|
- lib/rdstation/client.rb
|
126
127
|
- lib/rdstation/contacts.rb
|
127
128
|
- lib/rdstation/version.rb
|