equinox_crm 0.1.0 → 0.1.1
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/README.md +6 -8
- data/lib/equinox_crm/client.rb +39 -0
- data/lib/equinox_crm/contact.rb +26 -0
- data/lib/equinox_crm/version.rb +1 -1
- data/lib/equinox_crm.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5c13a978b831f1aa4c3be9dca516ba6f599c801b32b203397ae6352d1340246
|
4
|
+
data.tar.gz: e776b0a365c66524e6a685d60d54980c427acae00395ed6b275fa7cb7b6f9f10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9410550d3b3d209fef0af7c8dd2ff0df0657c0e937328671fe7e3d397b883ea07a9a700c3dcef5d449bfac61c17182f794a06b6e509730bcb84e918b96782391
|
7
|
+
data.tar.gz: f98a140e1d88373ed52912ab3b1f9136639640b699f129964b5b3bffb6daa7c060519709d68b7bd3488f76d19a0af5040cc1d090f29248bb942003705a0e7ee0
|
data/README.md
CHANGED
@@ -24,21 +24,19 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
TODO: Write usage instructions here
|
28
|
-
|
29
27
|
To fetch a specific contact
|
30
28
|
|
31
|
-
@client = EquinoxCrm::Client.new('YOUR_API_KEY')
|
32
|
-
@client.contacts('ID')
|
29
|
+
@client = EquinoxCrm::Client.new('YOUR_API_KEY')
|
30
|
+
@client.contacts('ID')
|
33
31
|
|
34
32
|
To fetch list of contacts
|
35
33
|
|
36
|
-
@client = EquinoxCrm::Client.new('YOUR_API_KEY')
|
37
|
-
@client.contacts_list
|
34
|
+
@client = EquinoxCrm::Client.new('YOUR_API_KEY')
|
35
|
+
@client.contacts_list
|
38
36
|
|
39
37
|
Default limit is 10 records. To fect more or less 10 records user limit param
|
40
38
|
|
41
|
-
@client.contacts_list(limit: 20)
|
39
|
+
@client.contacts_list(limit: 20)
|
42
40
|
|
43
41
|
If the result contains next_page attribute is null means list is over.
|
44
42
|
|
@@ -56,4 +54,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
56
54
|
|
57
55
|
## Code of Conduct
|
58
56
|
|
59
|
-
Everyone interacting in the EquinoxCrm project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/reliadvisor/equinox_crm/blob/master/CODE_OF_CONDUCT.md).
|
57
|
+
Everyone interacting in the EquinoxCrm project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/reliadvisor/equinox_crm/blob/master/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/core_ext'
|
5
|
+
|
6
|
+
module EquinoxCrm
|
7
|
+
class Client
|
8
|
+
include Contact
|
9
|
+
attr_reader :oauth_token
|
10
|
+
|
11
|
+
def initialize(oauth_token = nil)
|
12
|
+
@oauth_token = oauth_token
|
13
|
+
end
|
14
|
+
|
15
|
+
def contacts(id)
|
16
|
+
find(id)
|
17
|
+
end
|
18
|
+
|
19
|
+
def contacts_list(options = nil)
|
20
|
+
all(options)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def client
|
26
|
+
@_client ||= Faraday.new(API_URL) do |client|
|
27
|
+
client.request :url_encoded
|
28
|
+
client.adapter Faraday.default_adapter
|
29
|
+
client.headers['Authorization'] = "token #{oauth_token}" if oauth_token.present?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def request(http_method:, endpoint:, params: {})
|
34
|
+
response = client.public_send(http_method, endpoint, params)
|
35
|
+
JSON.parse(response.body)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
API_URL = "http://203.193.173.114:4000/api/public_access/contacts"
|
5
|
+
|
6
|
+
module Contact
|
7
|
+
|
8
|
+
def find(id)
|
9
|
+
response = request(
|
10
|
+
http_method: :get,
|
11
|
+
endpoint: "#{API_URL}/#{id}"
|
12
|
+
)
|
13
|
+
response
|
14
|
+
end
|
15
|
+
|
16
|
+
def all(options)
|
17
|
+
limit = options && options[:limit]
|
18
|
+
page = options && options[:page]
|
19
|
+
response = request(
|
20
|
+
http_method: :get,
|
21
|
+
endpoint: "#{API_URL}?limit=#{limit}&page=#{page}"
|
22
|
+
)
|
23
|
+
response
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/equinox_crm/version.rb
CHANGED
data/lib/equinox_crm.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: equinox_crm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- radv.ss.dev1
|
@@ -126,6 +126,8 @@ files:
|
|
126
126
|
- bin/setup
|
127
127
|
- equinox_crm.gemspec
|
128
128
|
- lib/equinox_crm.rb
|
129
|
+
- lib/equinox_crm/client.rb
|
130
|
+
- lib/equinox_crm/contact.rb
|
129
131
|
- lib/equinox_crm/version.rb
|
130
132
|
homepage: https://www.equinoxcrm.com/
|
131
133
|
licenses:
|