ruby-redtail 0.1.0 → 0.2.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 +8 -8
- data/README.rdoc +42 -4
- data/VERSION +1 -1
- data/lib/core_extensions/string.rb +9 -0
- data/lib/ruby-redtail.rb +2 -0
- data/lib/ruby-redtail/authentication.rb +12 -0
- data/lib/ruby-redtail/client.rb +19 -0
- data/lib/ruby-redtail/contact.rb +134 -0
- data/lib/ruby-redtail/contact/accounts.rb +26 -0
- data/lib/ruby-redtail/{activities.rb → contact/activities.rb} +0 -0
- data/lib/ruby-redtail/{addresses.rb → contact/addresses.rb} +0 -0
- data/lib/ruby-redtail/{notes.rb → contact/notes.rb} +0 -0
- data/lib/ruby-redtail/{tag_groups.rb → contact/tag_groups.rb} +0 -0
- data/lib/ruby-redtail/query.rb +1 -1
- data/lib/ruby-redtail/setting.rb +14 -0
- data/lib/ruby-redtail/sso.rb +12 -0
- data/lib/ruby-redtail/user.rb +22 -42
- data/lib/ruby-redtail/user/contacts.rb +91 -0
- data/lib/ruby-redtail/user/settings.rb +97 -0
- data/ruby-redtail.gemspec +19 -10
- data/test/contact_test.rb +25 -0
- data/test/helper.rb +2 -1
- data/test/user_contacts_test.rb +30 -0
- data/test/user_settings_test.rb +70 -0
- data/test/user_test.rb +15 -21
- metadata +20 -13
- data/lib/ruby-redtail/accounts.rb +0 -23
- data/lib/ruby-redtail/contacts.rb +0 -118
- data/lib/ruby-redtail/settings.rb +0 -31
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjlmM2JlNWRiZmNhYjFlYTk0MThkYTQ1YTdlY2MxNDcyN2ExYTNkOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDZhMDlkYWEyMTQ4NDc3ZWZiNjFjYTliM2ExMGUzYTNjOGI2YjMyNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjI2Zjk1M2U3NTAzZDE2YTU1MTkxMzcxZDdkYjQ5NDlkY2YwOTZlNGQ2MGJl
|
10
|
+
NjM2OTg0ODZiZjUyYTgxMzVkOTQ3MTNhOWJkYTlmMTQzNzkwNDc0NDFmMWZm
|
11
|
+
MTg1MDc4MmQ3OTJmMDBlZTYzNTZiNTc1ZDEyNmE4N2E2MGQ3OGU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTQ1Y2MxNzIyM2FkZTY1ZGRhNmMzYmRhNTI3ZGJhOGM3ZDQxMTExOWZhNTM0
|
14
|
+
OTZhOTRlNDU1NjZiNGZmYjNhZDNkZjRlZDZjMzRhZGUyYmViMmY1ZDJhZTM5
|
15
|
+
YTAwOThkMjU2NjZjNGIxNGExNjE5ZjgwZmY0MmIxMjA3Y2NiOGQ=
|
data/README.rdoc
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
=
|
1
|
+
= RubyRedtail
|
2
2
|
|
3
|
-
|
3
|
+
http://static.brandnewbox.com/misc/ruby-redtail.png
|
4
|
+
|
5
|
+
The gem provides access to methods to use the Redtail CRM API.
|
4
6
|
|
5
7
|
== Installation
|
6
8
|
|
@@ -18,15 +20,51 @@ Or install it yourself as:
|
|
18
20
|
|
19
21
|
== Basic Setup
|
20
22
|
|
21
|
-
|
23
|
+
To setup the client, you'll need the following configuration. In Rails land, you could create a file in `config/initializers/ruby-redtail.rb` (and if you're still storing top secret keys in your code repository, take the opportunity now to stop and start using ENV vars or something):
|
22
24
|
|
23
25
|
RubyRedtail.configure do |config|
|
24
26
|
config.api_key = ENV['REDTAIL_API_KEY']
|
25
27
|
config.secret_key = ENV['REDTAIL_SECRET_KEY']
|
26
28
|
config.api_uri = ENV['REDTAIL_API_URI']
|
27
29
|
end
|
30
|
+
|
31
|
+
== Basic Usage
|
32
|
+
|
33
|
+
=== Authentication Options
|
34
|
+
|
35
|
+
Block-tastic!
|
36
|
+
|
37
|
+
RubyRedtail::User.authenticate_via_basic('frank', 'secret') do |redtail_user|
|
38
|
+
# Something Cool
|
39
|
+
end
|
40
|
+
RubyRedtail::User.authenticate_via_user_key('key') do |redtail_user|
|
41
|
+
# Something Cool
|
42
|
+
end
|
43
|
+
RubyRedtail::User.authenticate_via_user_token('token') do |redtail_user|
|
44
|
+
# Something Cool
|
45
|
+
end
|
46
|
+
|
47
|
+
This works too:
|
48
|
+
|
49
|
+
redtail_user = RubyRedtail::User.new('Basic','frank', 'secret')
|
50
|
+
redtail_user = RubyRedtail::User.new('UserKey','key')
|
51
|
+
redtail_user = RubyRedtail::User.new('UserToken','token')
|
52
|
+
|
53
|
+
=== Fetching UserKey
|
54
|
+
|
55
|
+
|
56
|
+
redtail_user.user_key
|
57
|
+
|
58
|
+
|
59
|
+
=== Fetching Settings
|
60
|
+
|
61
|
+
redtail_user.settings.taggroups
|
62
|
+
|
63
|
+
=== Fetching Contacts
|
64
|
+
|
65
|
+
redtail_user.contacts.search_by_name('Investor')
|
28
66
|
|
29
|
-
== Contributing to
|
67
|
+
== Contributing to RubyRedtail
|
30
68
|
|
31
69
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
32
70
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/ruby-redtail.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
module RubyRedtail
|
2
|
+
class Authentication
|
3
|
+
def initialize(authentication = {})
|
4
|
+
raise ArgumentError if authentication.class != Hash
|
5
|
+
authentication.each do |key, value|
|
6
|
+
key = key.underscore
|
7
|
+
self.class.send :attr_accessor, key
|
8
|
+
instance_variable_set "@#{key}", value
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module RubyRedtail
|
2
|
+
class Client < RubyRedtail::Contact
|
3
|
+
# http://help.redtailtechnology.com/entries/21654562-authentication-methods
|
4
|
+
def initialize(client = {}, api_hash)
|
5
|
+
@api_hash = api_hash
|
6
|
+
|
7
|
+
raise ArgumentError unless client['ClientID']
|
8
|
+
@id = client['ClientID']
|
9
|
+
|
10
|
+
raise ArgumentError if client.class != Hash
|
11
|
+
client.each do |key, value|
|
12
|
+
key = key.underscore
|
13
|
+
self.class.send :attr_accessor, key
|
14
|
+
instance_variable_set "@#{key}", value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
module RubyRedtail
|
2
|
+
class Contact
|
3
|
+
attr_accessor :api_hash, :id
|
4
|
+
|
5
|
+
# http://help.redtailtechnology.com/entries/21654562-authentication-methods
|
6
|
+
def initialize(contact = {}, api_hash)
|
7
|
+
@api_hash = api_hash
|
8
|
+
|
9
|
+
raise ArgumentError unless contact['ContactID']
|
10
|
+
@id = contact['ContactID']
|
11
|
+
|
12
|
+
raise ArgumentError if contact.class != Hash
|
13
|
+
contact.each do |key, value|
|
14
|
+
key = key.underscore
|
15
|
+
self.class.send :attr_accessor, key
|
16
|
+
instance_variable_set "@#{key}", value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def addresses
|
22
|
+
RubyRedtail::Contact::Addresses.new self.api_hash
|
23
|
+
end
|
24
|
+
|
25
|
+
def notes
|
26
|
+
RubyRedtail::Contact::Notes.new self.api_hash
|
27
|
+
end
|
28
|
+
|
29
|
+
def accounts
|
30
|
+
RubyRedtail::Contact::Accounts.new self.api_hash
|
31
|
+
end
|
32
|
+
|
33
|
+
def activities
|
34
|
+
RubyRedtail::Contact::Activities.new self.api_hash
|
35
|
+
end
|
36
|
+
|
37
|
+
def tag_groups
|
38
|
+
RubyRedtail::Contact::TagGroups.new self.api_hash
|
39
|
+
end
|
40
|
+
|
41
|
+
# Fetch Contact By Contact Id
|
42
|
+
# Optional parameter: ?recent={recent}*
|
43
|
+
# * {0} does nothing
|
44
|
+
# * {1} updates recently viewed
|
45
|
+
def fetch (recent = false, basic = false)
|
46
|
+
RubyRedtail::Query.run("contacts/#{self.id}?recent=#{recent ? 1 : 0}", @api_hash, "GET")
|
47
|
+
end
|
48
|
+
|
49
|
+
# Fetch Basic Contact By Contact Id
|
50
|
+
# Optional parameter: ?recent={recent}*
|
51
|
+
# * {0} does nothing
|
52
|
+
# * {1} updates recently viewed
|
53
|
+
def fetch_basic (recent = false, basic = false)
|
54
|
+
RubyRedtail::Query.run("contacts/#{self.id}/basic?recent=#{recent ? 1 : 0}", @api_hash, "GET")
|
55
|
+
end
|
56
|
+
|
57
|
+
# Master Fetch Contact
|
58
|
+
# http://help.redtailtechnology.com/entries/22846682-master-fetch-contacts-contactid-master
|
59
|
+
def fetch_master
|
60
|
+
RubyRedtail::Query.run("contacts/#{self.id}/master", @api_hash, 'GET')
|
61
|
+
end
|
62
|
+
|
63
|
+
# Update Contact
|
64
|
+
def update (params)
|
65
|
+
RubyRedtail::Query.run("contacts/#{self.id}", @api_hash, 'PUT', params)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Delete Contact
|
69
|
+
def delete
|
70
|
+
RubyRedtail::Query.run("contacts/#{self.id}", @api_hash, 'DELETE')['Status'] == 0
|
71
|
+
end
|
72
|
+
|
73
|
+
# Fetch Contact Details
|
74
|
+
def details
|
75
|
+
RubyRedtail::Query.run("contacts/#{self.id}/details", @api_hash, "GET")
|
76
|
+
end
|
77
|
+
|
78
|
+
# Update Contact Details
|
79
|
+
# Is this required? (Deprecated on API website). Ask Client?
|
80
|
+
def update_details (params)
|
81
|
+
RubyRedtail::Query.run("contacts/#{self.id}/details", @api_hash, 'PUT', params)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Fetch Contact Family
|
85
|
+
def family
|
86
|
+
RubyRedtail::Query.run("contacts/#{self.id}/family", @api_hash, "GET")
|
87
|
+
end
|
88
|
+
|
89
|
+
# Fetch Contact Memberships
|
90
|
+
def memberships
|
91
|
+
RubyRedtail::Query.run("contacts/#{self.id}/memberships", @api_hash, "GET")
|
92
|
+
end
|
93
|
+
|
94
|
+
# Fetch Contact Personal Profile
|
95
|
+
def personal_profile
|
96
|
+
RubyRedtail::Query.run("contacts/#{self.id}/personalprofile", @api_hash, "GET")
|
97
|
+
end
|
98
|
+
|
99
|
+
# Update Contact Personal Profile
|
100
|
+
def update_personal_profile (personal_profile_id, params)
|
101
|
+
RubyRedtail::Query.run("contacts/#{self.id}/personalprofile/#{personal_profile_id}", @api_hash, 'PUT', params)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Fetch Contact Important Information
|
105
|
+
def inportant_information
|
106
|
+
RubyRedtail::Query.run("contacts/#{self.id}/importantinfo", @api_hash, "GET")
|
107
|
+
end
|
108
|
+
|
109
|
+
# Update Contact Important Information
|
110
|
+
def update_important_information (params)
|
111
|
+
RubyRedtail::Query.run("contacts/#{self.id}/importantinfo", @api_hash, 'PUT', params)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Fetch Contact Departments
|
115
|
+
def departments
|
116
|
+
RubyRedtail::Query.run("contacts/#{self.id}/importantinfo", @api_hash, "GET")
|
117
|
+
end
|
118
|
+
|
119
|
+
# Fetch User Defined Fields for Contact
|
120
|
+
def user_defined_fields
|
121
|
+
RubyRedtail::Query.run("contacts/#{self.id}/udf", @api_hash, "GET")
|
122
|
+
end
|
123
|
+
|
124
|
+
# Update User Defined Field for Contact
|
125
|
+
def update_user_defined_field (udf_id, params)
|
126
|
+
RubyRedtail::Query.run("contacts/#{self.id}/udf/#{udf_id}", @api_hash, 'PUT', params)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Create User Defined Field for Contact
|
130
|
+
def create_user_defined_field (params)
|
131
|
+
update_user_defined_field(self.id, 0, params)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module RubyRedtail
|
2
|
+
class Contact
|
3
|
+
class Accounts
|
4
|
+
def initialize(contact_id, api_hash)
|
5
|
+
@api_hash = api_hash
|
6
|
+
@contact_id = contact_id
|
7
|
+
end
|
8
|
+
|
9
|
+
def fetch
|
10
|
+
RubyRedtail::Query.run("contacts/#{@contact_id}/accounts", @api_hash, "GET")
|
11
|
+
end
|
12
|
+
|
13
|
+
def create (params)
|
14
|
+
update(@contact_id, 0, params)
|
15
|
+
end
|
16
|
+
|
17
|
+
def update (account_id, params)
|
18
|
+
RubyRedtail::Query.run("contacts/#{contact_id}/accounts/#{account_id}", @api_hash, 'PUT', params)
|
19
|
+
end
|
20
|
+
|
21
|
+
def assets (account_id)
|
22
|
+
RubyRedtail::Query.run("contacts/#{contact_id}/#{account_id}/assets", @api_hash, "GET")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/ruby-redtail/query.rb
CHANGED
@@ -3,7 +3,7 @@ module RubyRedtail
|
|
3
3
|
# TODO: Refactor (Lots of repetition)
|
4
4
|
def self.run (uri, auth_hash, method, request_body = nil)
|
5
5
|
base_uri = RubyRedtail.config.api_uri
|
6
|
-
if method == "GET"
|
6
|
+
if method == "GET"
|
7
7
|
@response = HTTParty.get(base_uri + uri, :headers => {"Authorization" => auth_hash, 'Content-Type' => 'text/json'}).parsed_response
|
8
8
|
elsif method == "POST"
|
9
9
|
@response = HTTParty.post(base_uri + uri, :headers => {"Authorization" => auth_hash, 'Content-Type' => 'text/json'}, :body => request_body.to_json).parsed_response
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RubyRedtail
|
2
|
+
class Setting
|
3
|
+
def initialize(setting = {},api_hash)
|
4
|
+
@api_hash = api_hash
|
5
|
+
|
6
|
+
raise ArgumentError if setting.class != Hash
|
7
|
+
setting.each do |key, value|
|
8
|
+
key = key.underscore
|
9
|
+
self.class.send :attr_accessor, key
|
10
|
+
instance_variable_set "@#{key}", value
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/ruby-redtail/user.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
require 'ruby-redtail/contacts'
|
2
|
-
require 'ruby-redtail/
|
3
|
-
require 'ruby-redtail/
|
4
|
-
require 'ruby-redtail/
|
5
|
-
require 'ruby-redtail/activities'
|
6
|
-
require 'ruby-redtail/tag_groups'
|
7
|
-
require 'ruby-redtail/settings'
|
1
|
+
require 'ruby-redtail/user/contacts'
|
2
|
+
require 'ruby-redtail/user/settings'
|
3
|
+
require 'ruby-redtail/authentication'
|
4
|
+
require 'ruby-redtail/sso'
|
8
5
|
|
9
6
|
module RubyRedtail
|
10
7
|
class User
|
11
8
|
attr_accessor :api_hash
|
12
9
|
|
10
|
+
# http://help.redtailtechnology.com/entries/21654562-authentication-methods
|
13
11
|
def initialize type, *args
|
14
12
|
if type == "Basic"
|
15
13
|
self.api_hash = "Basic " + Base64.strict_encode64("#{RubyRedtail.config.api_key}:#{args[0]}:#{args[1]}")
|
@@ -34,51 +32,33 @@ module RubyRedtail
|
|
34
32
|
yield self.new('UserToken',token)
|
35
33
|
end
|
36
34
|
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
# else
|
44
|
-
# super
|
45
|
-
# end
|
46
|
-
# end
|
47
|
-
|
35
|
+
# UserKey Retrieval
|
36
|
+
# http://help.redtailtechnology.com/entries/22621068
|
37
|
+
# returns a UserKey in exchange for the Username and Password specified in the Authentication.
|
38
|
+
def user_key
|
39
|
+
authentication.user_key
|
40
|
+
end
|
48
41
|
def authentication
|
49
|
-
RubyRedtail::Query.run("authentication", self.api_hash, "GET")
|
42
|
+
RubyRedtail::Authentication.new(RubyRedtail::Query.run("authentication", self.api_hash, "GET"))
|
50
43
|
end
|
51
44
|
|
45
|
+
# Single Sign-On
|
46
|
+
# http://help.redtailtechnology.com/entries/22602246
|
47
|
+
# returns a URL for Single Sign-On based on the specified endpoint.
|
48
|
+
# TODO: pass endpoint and id parameters
|
49
|
+
def sso_return_url
|
50
|
+
sso.return_url
|
51
|
+
end
|
52
52
|
def sso
|
53
|
-
|
53
|
+
RubyRedtail::Sso.new(RubyRedtail::Query.run("sso", self.api_hash, "GET"))
|
54
54
|
end
|
55
55
|
|
56
56
|
def contacts
|
57
|
-
RubyRedtail::Contacts.new self.api_hash
|
58
|
-
end
|
59
|
-
|
60
|
-
def addresses
|
61
|
-
RubyRedtail::Addresses.new self.api_hash
|
62
|
-
end
|
63
|
-
|
64
|
-
def notes
|
65
|
-
RubyRedtail::Notes.new self.api_hash
|
66
|
-
end
|
67
|
-
|
68
|
-
def accounts
|
69
|
-
RubyRedtail::Accounts.new self.api_hash
|
70
|
-
end
|
71
|
-
|
72
|
-
def activities
|
73
|
-
RubyRedtail::Activities.new self.api_hash
|
74
|
-
end
|
75
|
-
|
76
|
-
def tag_groups
|
77
|
-
RubyRedtail::TagGroups.new self.api_hash
|
57
|
+
RubyRedtail::User::Contacts.new self.api_hash
|
78
58
|
end
|
79
59
|
|
80
60
|
def settings
|
81
|
-
RubyRedtail::Settings.new self.api_hash
|
61
|
+
RubyRedtail::User::Settings.new self.api_hash
|
82
62
|
end
|
83
63
|
end
|
84
64
|
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'ruby-redtail/contact'
|
2
|
+
require 'ruby-redtail/client'
|
3
|
+
|
4
|
+
module RubyRedtail
|
5
|
+
class User
|
6
|
+
class Contacts
|
7
|
+
|
8
|
+
CONTACT_SEARCH_FIELDS = ['LastUpdate','Name','RecAdd','PhoneNumber','Tag_Group','FirstName','LastName','FamilyName','FamilyHead','ClientStatus','ContactType','ClientSource','TaxId']
|
9
|
+
CONTACT_SEARCH_OPERANDS = ['=','>','<','!=','Like','BeginsWith','IsEmpty']
|
10
|
+
|
11
|
+
def initialize(api_hash)
|
12
|
+
@api_hash = api_hash
|
13
|
+
end
|
14
|
+
|
15
|
+
# Contact Search by Name Fetch
|
16
|
+
# returns a paged list of limited Contact Information, including the ContactID
|
17
|
+
# *value = searched name
|
18
|
+
# *page = pagination
|
19
|
+
# http://help.redtailtechnology.com/entries/21937828-contacts-search-contacts-search
|
20
|
+
def search_by_name (value, page = 1)
|
21
|
+
build_contacts_array RubyRedtail::Query.run("contacts/search?value=#{value}&page=#{page}", @api_hash, "GET")["Contacts"]
|
22
|
+
end
|
23
|
+
|
24
|
+
# Contact Search by Letter Fetch
|
25
|
+
# returns a paged list of limited Contact Information, including the ContactID,
|
26
|
+
# based on a partial name or a single character.
|
27
|
+
# *value = searched beginning letter(s)
|
28
|
+
# *page = pagination
|
29
|
+
# http://help.redtailtechnology.com/entries/21937828-contacts-search-contacts-search
|
30
|
+
def search_by_letter (value, page = 1)
|
31
|
+
build_contacts_array RubyRedtail::Query.run("contacts/search/beginswith?value=#{value}&page=#{page}", @api_hash, "GET")["Contacts"]
|
32
|
+
end
|
33
|
+
|
34
|
+
# TODO: Test this properly
|
35
|
+
# Search Contact by Custom Query
|
36
|
+
# returns a paged list of Basic Contact Information, including the ContactID,
|
37
|
+
# based on the specified field, operand, and field value.
|
38
|
+
# http://help.redtailtechnology.com/entries/22550401
|
39
|
+
def search (query, page = 1)
|
40
|
+
body = Array.new(query.length) { {} }
|
41
|
+
query.each_with_index do |expr, i|
|
42
|
+
body[i]["Field"] = CONTACT_SEARCH_FIELDS.index(expr[0]).to_s
|
43
|
+
body[i]["Operand"] = CONTACT_SEARCH_OPERANDS.index(expr[1]).to_s
|
44
|
+
body[i]["Value"] = expr[2]
|
45
|
+
end
|
46
|
+
build_clients_array RubyRedtail::Query.run("contacts/search?page=#{page}", @api_hash, "POST", body)["Contacts"]
|
47
|
+
end
|
48
|
+
|
49
|
+
# Create New Contact
|
50
|
+
def create (params)
|
51
|
+
update(0, params)
|
52
|
+
end
|
53
|
+
|
54
|
+
protected
|
55
|
+
|
56
|
+
def build_contact contact_hash
|
57
|
+
if contact_hash
|
58
|
+
RubyRedtail::Contact.new(contact_hash,@api_hash)
|
59
|
+
else
|
60
|
+
raise RubyRedtail::AuthenticationError
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def build_contacts_array contact_hashes
|
65
|
+
if client_hashes
|
66
|
+
contact_hashes.collect { |contact_hash| self.build_contact contact_hash }
|
67
|
+
else
|
68
|
+
raise RubyRedtail::AuthenticationError
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def build_client client_hash
|
73
|
+
if client_hash
|
74
|
+
RubyRedtail::Client.new(client_hash,@api_hash)
|
75
|
+
else
|
76
|
+
raise RubyRedtail::AuthenticationError
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def build_clients_array client_hashes
|
81
|
+
if client_hashes
|
82
|
+
client_hashes.collect { |client_hash| self.build_client client_hash }
|
83
|
+
else
|
84
|
+
raise RubyRedtail::AuthenticationError
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'ruby-redtail/setting'
|
2
|
+
|
3
|
+
module RubyRedtail
|
4
|
+
class User
|
5
|
+
class Settings
|
6
|
+
|
7
|
+
def initialize api_hash
|
8
|
+
@api_hash = api_hash
|
9
|
+
end
|
10
|
+
|
11
|
+
# Activity Type List Fetch
|
12
|
+
# returns a list of activity types with the corresponding Activity Code
|
13
|
+
def activitytypes
|
14
|
+
build_settings_array RubyRedtail::Query.run("settings/activitytypes", @api_hash, "GET")
|
15
|
+
end
|
16
|
+
|
17
|
+
# Master Category List Fetch
|
18
|
+
# returns a Master Category List with the corresponding MCL Code.
|
19
|
+
def mcl
|
20
|
+
build_settings_array RubyRedtail::Query.run("settings/mcl", @api_hash, "GET")
|
21
|
+
end
|
22
|
+
|
23
|
+
# Salutation List Fetch
|
24
|
+
# returns a list of Salutations with the corresponding Salutation Code
|
25
|
+
def salutations
|
26
|
+
build_settings_array RubyRedtail::Query.run("settings/salutations", @api_hash, "GET")
|
27
|
+
end
|
28
|
+
|
29
|
+
# User-Defined Fields Fetch
|
30
|
+
# returns a list of User-defined fields with the corresponding UDF Code.
|
31
|
+
def udf
|
32
|
+
build_settings_array RubyRedtail::Query.run("settings/udf", @api_hash, "GET")
|
33
|
+
end
|
34
|
+
|
35
|
+
# Tag Groups Fetch
|
36
|
+
# returns a list of Tag Groups for a user's Database.
|
37
|
+
def taggroups
|
38
|
+
build_settings_array RubyRedtail::Query.run("settings/taggroups", @api_hash, "GET")
|
39
|
+
end
|
40
|
+
|
41
|
+
# Contact Status List Fetch
|
42
|
+
# returns a list of contact statuses with the corresponding Contact Status Code.
|
43
|
+
# optional Parameter: {deleted}*
|
44
|
+
# {0} shows current records, {1} shows deleted records
|
45
|
+
def csl(deleted=false)
|
46
|
+
build_settings_array RubyRedtail::Query.run("settings/csl?deleted=#{deleted ? 1 : 0}", @api_hash, "GET")
|
47
|
+
end
|
48
|
+
|
49
|
+
# Contact Category List Fetch
|
50
|
+
# returns a list of Contact Categories with the corresponding Contact Category Code
|
51
|
+
# optional Parameter: {deleted}*
|
52
|
+
# {0} shows current records, {1} shows deleted records
|
53
|
+
def mccl(deleted=false)
|
54
|
+
build_settings_array RubyRedtail::Query.run("settings/mccl?deleted=#{deleted ? 1 : 0}", @api_hash, "GET")
|
55
|
+
end
|
56
|
+
|
57
|
+
# Contact Source List Fetch
|
58
|
+
# returns a list of Contact Sources with the corresponding Contact Source Code
|
59
|
+
# optional Parameter: {deleted}*
|
60
|
+
# {0} shows current records, {1} shows deleted records
|
61
|
+
def mcsl(deleted=false)
|
62
|
+
build_settings_array RubyRedtail::Query.run("settings/mcsl?deleted=#{deleted ? 1 : 0}", @api_hash, "GET")
|
63
|
+
end
|
64
|
+
|
65
|
+
# Servicing Advisor List Fetch
|
66
|
+
# returns a list of Servicing Advisors with the corresponding Servicing Advisor Code.
|
67
|
+
# optional Parameter: {deleted}*
|
68
|
+
# {0} shows current records, {1} shows deleted records
|
69
|
+
def sal(deleted=false)
|
70
|
+
build_settings_array RubyRedtail::Query.run("settings/sal?deleted=#{deleted ? 1 : 0}", @api_hash, "GET")
|
71
|
+
end
|
72
|
+
|
73
|
+
# Writing Advisor List Fetch
|
74
|
+
# returns a list of Writing Advisors with the corresponding Writing Advisor Code.
|
75
|
+
# optional Parameter: {deleted}*
|
76
|
+
# {0} shows current records, {1} shows deleted records
|
77
|
+
def wal(deleted=false)
|
78
|
+
build_settings_array RubyRedtail::Query.run("settings/wal?deleted=#{deleted ? 1 : 0}", @api_hash, "GET")
|
79
|
+
end
|
80
|
+
|
81
|
+
protected
|
82
|
+
|
83
|
+
def build_setting setting_hash
|
84
|
+
RubyRedtail::Setting.new(setting_hash,@api_hash)
|
85
|
+
end
|
86
|
+
|
87
|
+
def build_settings_array setting_hashes
|
88
|
+
if setting_hashes
|
89
|
+
setting_hashes.collect { |setting_hash| self.build_setting setting_hash }
|
90
|
+
else
|
91
|
+
raise RubyRedtail::AuthenticationError
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/ruby-redtail.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: ruby-redtail 0.
|
5
|
+
# stub: ruby-redtail 0.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "ruby-redtail"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.2.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Nathan Colgate"]
|
13
|
-
s.date = "2014-
|
13
|
+
s.date = "2014-04-28"
|
14
14
|
s.description = "The gem offers various methods to access the Redtail CRM API"
|
15
15
|
s.email = "nathan@brandnewbox.com"
|
16
16
|
s.extra_rdoc_files = [
|
@@ -26,19 +26,28 @@ Gem::Specification.new do |s|
|
|
26
26
|
"README.rdoc",
|
27
27
|
"Rakefile",
|
28
28
|
"VERSION",
|
29
|
+
"lib/core_extensions/string.rb",
|
29
30
|
"lib/ruby-redtail.rb",
|
30
|
-
"lib/ruby-redtail/
|
31
|
-
"lib/ruby-redtail/
|
32
|
-
"lib/ruby-redtail/
|
33
|
-
"lib/ruby-redtail/
|
31
|
+
"lib/ruby-redtail/authentication.rb",
|
32
|
+
"lib/ruby-redtail/client.rb",
|
33
|
+
"lib/ruby-redtail/contact.rb",
|
34
|
+
"lib/ruby-redtail/contact/accounts.rb",
|
35
|
+
"lib/ruby-redtail/contact/activities.rb",
|
36
|
+
"lib/ruby-redtail/contact/addresses.rb",
|
37
|
+
"lib/ruby-redtail/contact/notes.rb",
|
38
|
+
"lib/ruby-redtail/contact/tag_groups.rb",
|
34
39
|
"lib/ruby-redtail/exceptions.rb",
|
35
|
-
"lib/ruby-redtail/notes.rb",
|
36
40
|
"lib/ruby-redtail/query.rb",
|
37
|
-
"lib/ruby-redtail/
|
38
|
-
"lib/ruby-redtail/
|
41
|
+
"lib/ruby-redtail/setting.rb",
|
42
|
+
"lib/ruby-redtail/sso.rb",
|
39
43
|
"lib/ruby-redtail/user.rb",
|
44
|
+
"lib/ruby-redtail/user/contacts.rb",
|
45
|
+
"lib/ruby-redtail/user/settings.rb",
|
40
46
|
"ruby-redtail.gemspec",
|
47
|
+
"test/contact_test.rb",
|
41
48
|
"test/helper.rb",
|
49
|
+
"test/user_contacts_test.rb",
|
50
|
+
"test/user_settings_test.rb",
|
42
51
|
"test/user_test.rb"
|
43
52
|
]
|
44
53
|
s.homepage = "http://github.com/nathancolgate/ruby-redtail"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class ContactTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_redtail
|
6
|
+
@user = RubyRedtail::User.new('UserKey',@redtail_user_key)
|
7
|
+
@contact = RubyRedtail::Contact.new({"ContactID" => @redtail_contact_id},@user.api_hash)
|
8
|
+
end
|
9
|
+
|
10
|
+
should "be able to fetch client details" do
|
11
|
+
assert_equal(Hash, @contact.fetch.class)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be able to fetch basic client details" do
|
15
|
+
assert_equal(Hash, @contact.fetch_basic.class)
|
16
|
+
end
|
17
|
+
|
18
|
+
should "be able to fetch master client details" do
|
19
|
+
assert_equal(Hash, @contact.fetch_master.class)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
end
|
data/test/helper.rb
CHANGED
@@ -15,13 +15,14 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
15
15
|
require 'ruby-redtail'
|
16
16
|
|
17
17
|
class Test::Unit::TestCase
|
18
|
-
def
|
18
|
+
def setup_redtail
|
19
19
|
@redtail_api_key = 'E45FC97D-5AB2-4FD7-B05F-80BC64227A80'
|
20
20
|
@redtail_secret_key = '31CE58601D694E31B681C209D29936F6'
|
21
21
|
@redtail_uri = 'http://dev.api2.redtailtechnology.com/crm/v1/rest'
|
22
22
|
@redtail_user_key = 'CF5DAEC8-4F73-404C-9F1A-8C944F2DDC51'
|
23
23
|
@redtail_user_name = 'Statementone'
|
24
24
|
@redtail_user_password = 'sonedemo'
|
25
|
+
@redtail_contact_id = 1624478 # Mary Investor
|
25
26
|
@num = 4
|
26
27
|
RubyRedtail.configure do |config|
|
27
28
|
config.api_key = @redtail_api_key
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class UserContactsTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_redtail
|
6
|
+
@user = RubyRedtail::User.new('UserKey',@redtail_user_key)
|
7
|
+
end
|
8
|
+
|
9
|
+
should "be able to search contacts by name" do
|
10
|
+
contacts = @user.contacts.search_by_name('Investor')
|
11
|
+
assert_equal(Array, contacts.class)
|
12
|
+
assert_equal(RubyRedtail::Contact, contacts.first.class)
|
13
|
+
end
|
14
|
+
|
15
|
+
should "be able to search contacts by letter" do
|
16
|
+
contacts = @user.contacts.search_by_letter('m')
|
17
|
+
assert_equal(Array, contacts.class)
|
18
|
+
assert_equal(RubyRedtail::Contact, contacts.first.class)
|
19
|
+
end
|
20
|
+
|
21
|
+
should "be able to search with that fancy method" do
|
22
|
+
clients = @user.contacts.search([
|
23
|
+
['FirstName','=',"Mary"],
|
24
|
+
['LastName','=',"Investor"]
|
25
|
+
])
|
26
|
+
assert_equal(Array, clients.class)
|
27
|
+
assert_equal(RubyRedtail::Client, clients.first.class)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class UserSettingsTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_redtail
|
6
|
+
@user = RubyRedtail::User.new('UserKey',@redtail_user_key)
|
7
|
+
end
|
8
|
+
|
9
|
+
should "be able to fetch user activitytypes" do
|
10
|
+
activitytypes = @user.settings.activitytypes
|
11
|
+
assert_equal(Array, activitytypes.class)
|
12
|
+
assert_equal(RubyRedtail::Setting, activitytypes.first.class)
|
13
|
+
end
|
14
|
+
|
15
|
+
should "be able to fetch user mcl" do
|
16
|
+
mcl = @user.settings.mcl
|
17
|
+
assert_equal(Array, mcl.class)
|
18
|
+
assert_equal(RubyRedtail::Setting, mcl.first.class)
|
19
|
+
end
|
20
|
+
|
21
|
+
should "be able to fetch user salutations" do
|
22
|
+
salutations = @user.settings.salutations
|
23
|
+
assert_equal(Array, salutations.class)
|
24
|
+
assert_equal(RubyRedtail::Setting, salutations.first.class)
|
25
|
+
end
|
26
|
+
|
27
|
+
should "be able to fetch user udf" do
|
28
|
+
udf = @user.settings.udf
|
29
|
+
assert_equal(Array, udf.class)
|
30
|
+
assert_equal(RubyRedtail::Setting, udf.first.class)
|
31
|
+
end
|
32
|
+
|
33
|
+
should "be able to fetch user taggroups" do
|
34
|
+
taggroups = @user.settings.taggroups
|
35
|
+
assert_equal(Array, taggroups.class)
|
36
|
+
assert_equal(RubyRedtail::Setting, taggroups.first.class)
|
37
|
+
end
|
38
|
+
|
39
|
+
should "be able to fetch user csl" do
|
40
|
+
csl = @user.settings.csl
|
41
|
+
assert_equal(Array, csl.class)
|
42
|
+
assert_equal(RubyRedtail::Setting, csl.first.class)
|
43
|
+
end
|
44
|
+
|
45
|
+
should "be able to fetch user mccl" do
|
46
|
+
mccl = @user.settings.mccl
|
47
|
+
assert_equal(Array, mccl.class)
|
48
|
+
assert_equal(RubyRedtail::Setting, mccl.first.class)
|
49
|
+
end
|
50
|
+
|
51
|
+
should "be able to fetch user mcsl" do
|
52
|
+
mcsl = @user.settings.mcsl
|
53
|
+
assert_equal(Array, mcsl.class)
|
54
|
+
assert_equal(RubyRedtail::Setting, mcsl.first.class)
|
55
|
+
end
|
56
|
+
|
57
|
+
should "be able to fetch user sal" do
|
58
|
+
sal = @user.settings.sal
|
59
|
+
assert_equal(Array, sal.class)
|
60
|
+
assert_equal(RubyRedtail::Setting, sal.first.class)
|
61
|
+
end
|
62
|
+
|
63
|
+
should "be able to fetch user wal" do
|
64
|
+
wal = @user.settings.wal
|
65
|
+
assert_equal(Array, wal.class)
|
66
|
+
assert_equal(RubyRedtail::Setting, wal.first.class)
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
end
|
data/test/user_test.rb
CHANGED
@@ -1,72 +1,66 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class UserTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_redtail
|
6
|
+
end
|
4
7
|
|
5
8
|
should "be able to fetch UserKey via Basic authentication" do
|
6
9
|
user = RubyRedtail::User.new('Basic', @redtail_user_name, @redtail_user_password)
|
7
10
|
authentication = user.authentication
|
8
|
-
assert_equal("Success", authentication
|
9
|
-
assert_equal(41974, authentication
|
10
|
-
assert_equal(@redtail_user_key, authentication
|
11
|
+
assert_equal("Success", authentication.message)
|
12
|
+
assert_equal(41974, authentication.user_id)
|
13
|
+
assert_equal(@redtail_user_key, authentication.user_key)
|
11
14
|
end
|
12
15
|
|
13
16
|
should "be able to fetch user data via Basic authentication" do
|
14
17
|
user = RubyRedtail::User.new('Basic', @redtail_user_name, @redtail_user_password)
|
15
|
-
|
16
|
-
assert_equal(Array, tag_groups.class)
|
18
|
+
assert_nothing_raised(RubyRedtail::AuthenticationError) {taggroups = user.settings.taggroups }
|
17
19
|
end
|
18
20
|
|
19
21
|
should "be able to fetch user data via UserKey authentication" do
|
20
22
|
user = RubyRedtail::User.new('UserKey', @redtail_user_key)
|
21
|
-
|
22
|
-
assert_equal(Array, tag_groups.class)
|
23
|
+
assert_nothing_raised(RubyRedtail::AuthenticationError) {taggroups = user.settings.taggroups }
|
23
24
|
end
|
24
25
|
|
25
26
|
should "be able to fetch user data via UserToken authentication" do
|
26
27
|
# TODO: We need a user token
|
27
28
|
# user = RubyRedtail::User.new('UserToken',@redtail_user_token)
|
28
|
-
#
|
29
|
-
# assert_equal(Array,tag_groups.class)
|
29
|
+
# assert_nothing_raised(RubyRedtail::AuthenticationError) {taggroups = user.settings.taggroups }
|
30
30
|
end
|
31
31
|
|
32
32
|
should "be able to fetch user data via Basic authentication block" do
|
33
33
|
RubyRedtail::User.authenticate_via_basic(@redtail_user_name, @redtail_user_password) do |user|
|
34
|
-
|
35
|
-
assert_equal(Array, tag_groups.class)
|
34
|
+
assert_nothing_raised(RubyRedtail::AuthenticationError) {taggroups = user.settings.taggroups }
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
39
38
|
should "be able to fetch user data via UserKey authentication block" do
|
40
39
|
RubyRedtail::User.authenticate_via_user_key(@redtail_user_key) do |user|
|
41
|
-
|
42
|
-
assert_equal(Array, tag_groups.class)
|
40
|
+
assert_nothing_raised(RubyRedtail::AuthenticationError) {taggroups = user.settings.taggroups }
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
46
44
|
should "be able to fetch user data via UserToken authentication block" do
|
47
45
|
# TODO: We need a user token
|
48
46
|
# RubyRedtail::User.authenticate_via_user_token(@redtail_user_token) do |user|
|
49
|
-
#
|
50
|
-
# assert_equal(Array,tag_groups.class)
|
47
|
+
# assert_nothing_raised(RubyRedtail::AuthenticationError) {taggroups = user.settings.taggroups }
|
51
48
|
# end
|
52
49
|
end
|
53
50
|
|
54
51
|
should "not be able to fetch user data via faulty Basic authentication" do
|
55
52
|
user = RubyRedtail::User.new('Basic', @redtail_user_name, 'hacker_hackity_hack')
|
56
|
-
|
57
|
-
assert_equal(nil, tag_groups)
|
53
|
+
assert_raise(RubyRedtail::AuthenticationError) {taggroups = user.settings.taggroups }
|
58
54
|
end
|
59
55
|
|
60
56
|
should "not be able to fetch user data via faulty UserKey authentication" do
|
61
57
|
user = RubyRedtail::User.new('UserKey', 'hacker_hackity_hack')
|
62
|
-
|
63
|
-
assert_equal(nil, tag_groups)
|
58
|
+
assert_raise(RubyRedtail::AuthenticationError) {taggroups = user.settings.taggroups }
|
64
59
|
end
|
65
60
|
|
66
61
|
should "not be able to fetch user data via faulty UserToken authentication" do
|
67
62
|
user = RubyRedtail::User.new('UserToken', 'hacker_hackity_hack')
|
68
|
-
|
69
|
-
assert_equal(nil, tag_groups)
|
63
|
+
assert_raise(RubyRedtail::AuthenticationError) {taggroups = user.settings.taggroups }
|
70
64
|
end
|
71
65
|
|
72
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-redtail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Colgate
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -44,16 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
My4xMg==
|
47
|
+
version: '3.12'
|
49
48
|
type: :development
|
50
49
|
prerelease: false
|
51
50
|
version_requirements: !ruby/object:Gem::Requirement
|
52
51
|
requirements:
|
53
52
|
- - ~>
|
54
53
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
56
|
-
My4xMg==
|
54
|
+
version: '3.12'
|
57
55
|
- !ruby/object:Gem::Dependency
|
58
56
|
name: bundler
|
59
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,19 +124,28 @@ files:
|
|
126
124
|
- README.rdoc
|
127
125
|
- Rakefile
|
128
126
|
- VERSION
|
127
|
+
- lib/core_extensions/string.rb
|
129
128
|
- lib/ruby-redtail.rb
|
130
|
-
- lib/ruby-redtail/
|
131
|
-
- lib/ruby-redtail/
|
132
|
-
- lib/ruby-redtail/
|
133
|
-
- lib/ruby-redtail/
|
129
|
+
- lib/ruby-redtail/authentication.rb
|
130
|
+
- lib/ruby-redtail/client.rb
|
131
|
+
- lib/ruby-redtail/contact.rb
|
132
|
+
- lib/ruby-redtail/contact/accounts.rb
|
133
|
+
- lib/ruby-redtail/contact/activities.rb
|
134
|
+
- lib/ruby-redtail/contact/addresses.rb
|
135
|
+
- lib/ruby-redtail/contact/notes.rb
|
136
|
+
- lib/ruby-redtail/contact/tag_groups.rb
|
134
137
|
- lib/ruby-redtail/exceptions.rb
|
135
|
-
- lib/ruby-redtail/notes.rb
|
136
138
|
- lib/ruby-redtail/query.rb
|
137
|
-
- lib/ruby-redtail/
|
138
|
-
- lib/ruby-redtail/
|
139
|
+
- lib/ruby-redtail/setting.rb
|
140
|
+
- lib/ruby-redtail/sso.rb
|
139
141
|
- lib/ruby-redtail/user.rb
|
142
|
+
- lib/ruby-redtail/user/contacts.rb
|
143
|
+
- lib/ruby-redtail/user/settings.rb
|
140
144
|
- ruby-redtail.gemspec
|
145
|
+
- test/contact_test.rb
|
141
146
|
- test/helper.rb
|
147
|
+
- test/user_contacts_test.rb
|
148
|
+
- test/user_settings_test.rb
|
142
149
|
- test/user_test.rb
|
143
150
|
homepage: http://github.com/nathancolgate/ruby-redtail
|
144
151
|
licenses:
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module RubyRedtail
|
2
|
-
class Accounts
|
3
|
-
def initialize (api_hash)
|
4
|
-
@api_hash = api_hash
|
5
|
-
end
|
6
|
-
|
7
|
-
def fetch (contact_id)
|
8
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/accounts", @api_hash, "GET")
|
9
|
-
end
|
10
|
-
|
11
|
-
def update (contact_id, account_id, params)
|
12
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/accounts/#{account_id}", @api_hash, 'PUT', params)
|
13
|
-
end
|
14
|
-
|
15
|
-
def create (contact_id, params)
|
16
|
-
update(contact_id, 0, params)
|
17
|
-
end
|
18
|
-
|
19
|
-
def assets (contact_id, account_id)
|
20
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/#{account_id}/assets", @api_hash, "GET")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
module RubyRedtail
|
2
|
-
class Contacts
|
3
|
-
|
4
|
-
CONTACT_SEARCH_FIELDS = ['LastUpdate','Name','RecAdd','PhoneNumber','Tag_Group','FirstName','LastName','FamilyName','FamilyHead','ClientStatus','ContactType','ClientSource','TaxId']
|
5
|
-
CONTACT_SEARCH_OPERANDS = ['=','>','<','!=','Like','BeginsWith','IsEmpty']
|
6
|
-
|
7
|
-
def initialize(api_hash)
|
8
|
-
@api_hash = api_hash
|
9
|
-
end
|
10
|
-
|
11
|
-
# Search Contact By Name or Part of Name
|
12
|
-
def search_by_name (value, page = 1)
|
13
|
-
RubyRedtail::Query.run("contacts/search?value=#{value}&page=#{page}", @api_hash, "GET")["Contacts"]
|
14
|
-
end
|
15
|
-
|
16
|
-
# TODO: Test this properly
|
17
|
-
# Search Contact by Custom Query
|
18
|
-
def search (query, page = 1)
|
19
|
-
body = Array.new(query.length) { {} }
|
20
|
-
query.each_with_index do |expr, i|
|
21
|
-
body[i]["Field"] = CONTACT_SEARCH_FIELDS.index expr[0]
|
22
|
-
body[i]["Operand"] = CONTACT_SEARCH_OPERANDS.index expr[1]
|
23
|
-
body[i]["Value"] = expr[2]
|
24
|
-
end
|
25
|
-
RubyRedtail::Query.run("contacts/search?page=#{page}", @api_hash, "POST", body)
|
26
|
-
end
|
27
|
-
|
28
|
-
# Fetch Contact By Contact Id
|
29
|
-
def fetch (contact_id, recent = false, basic = false)
|
30
|
-
if basic
|
31
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/basic?recent=#{recent ? 1 : 0}", @api_hash, "GET")
|
32
|
-
else
|
33
|
-
RubyRedtail::Query.run("contacts/#{contact_id}?recent=#{recent ? 1 : 0}", @api_hash, "GET")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# Update Contact
|
38
|
-
def update (contact_id, params)
|
39
|
-
RubyRedtail::Query.run("contacts/#{contact_id}", @api_hash, 'PUT', params)
|
40
|
-
end
|
41
|
-
|
42
|
-
# Create New Contact
|
43
|
-
def create (params)
|
44
|
-
update(0, params)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Delete Contact
|
48
|
-
def delete (contact_id)
|
49
|
-
RubyRedtail::Query.run("contacts/#{contact_id}", @api_hash, 'DELETE')['Status'] == 0
|
50
|
-
end
|
51
|
-
|
52
|
-
# Master Fetch Contact
|
53
|
-
def master_fetch (contact_id)
|
54
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/master", @api_hash, 'GET')
|
55
|
-
end
|
56
|
-
|
57
|
-
# Fetch Contact Details
|
58
|
-
def details (contact_id)
|
59
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/details", @api_hash, "GET")
|
60
|
-
end
|
61
|
-
|
62
|
-
# Update Contact Details
|
63
|
-
# Is this required? (Deprecated on API website). Ask Client?
|
64
|
-
def update_details (contact_id, params)
|
65
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/details", @api_hash, 'PUT', params)
|
66
|
-
end
|
67
|
-
|
68
|
-
# Fetch Contact Family
|
69
|
-
def family (contact_id)
|
70
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/family", @api_hash, "GET")
|
71
|
-
end
|
72
|
-
|
73
|
-
# Fetch Contact Memberships
|
74
|
-
def memberships (contact_id)
|
75
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/memberships", @api_hash, "GET")
|
76
|
-
end
|
77
|
-
|
78
|
-
# Fetch Contact Personal Profile
|
79
|
-
def personal_profile (contact_id)
|
80
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/personalprofile", @api_hash, "GET")
|
81
|
-
end
|
82
|
-
|
83
|
-
# Update Contact Personal Profile
|
84
|
-
def update_personal_profile (contact_id, personal_profile_id, params)
|
85
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/personalprofile/#{personal_profile_id}", @api_hash, 'PUT', params)
|
86
|
-
end
|
87
|
-
|
88
|
-
# Fetch Contact Important Information
|
89
|
-
def inportant_information (contact_id)
|
90
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/importantinfo", @api_hash, "GET")
|
91
|
-
end
|
92
|
-
|
93
|
-
# Update Contact Important Information
|
94
|
-
def update_important_information (contact_id, params)
|
95
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/importantinfo", @api_hash, 'PUT', params)
|
96
|
-
end
|
97
|
-
|
98
|
-
# Fetch Contact Departments
|
99
|
-
def departments (contact_id)
|
100
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/importantinfo", @api_hash, "GET")
|
101
|
-
end
|
102
|
-
|
103
|
-
# Fetch User Defined Fields for Contact
|
104
|
-
def user_defined_fields (contact_id)
|
105
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/udf", @api_hash, "GET")
|
106
|
-
end
|
107
|
-
|
108
|
-
# Update User Defined Field for Contact
|
109
|
-
def update_user_defined_field (contact_id, udf_id, params)
|
110
|
-
RubyRedtail::Query.run("contacts/#{contact_id}/udf/#{udf_id}", @api_hash, 'PUT', params)
|
111
|
-
end
|
112
|
-
|
113
|
-
# Create User Defined Field for Contact
|
114
|
-
def create_user_defined_field (contact_id, params)
|
115
|
-
update_user_defined_field(contact_id, 0, params)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module RubyRedtail
|
2
|
-
class Settings
|
3
|
-
METHODS = {
|
4
|
-
:activity_types => 'activitytypes',
|
5
|
-
:master_categories => 'mcl',
|
6
|
-
:salutations => 'salutations',
|
7
|
-
:user_defined_fields => 'udf',
|
8
|
-
:tag_groups => 'taggroups'
|
9
|
-
}
|
10
|
-
METHODS_WITH_DELETE = {
|
11
|
-
:contact_statuses => 'csl',
|
12
|
-
:contact_categories => 'mccl',
|
13
|
-
:contact_sources => 'mcsl',
|
14
|
-
:servicing_advisors => 'sal',
|
15
|
-
:writing_advisors => 'wal'
|
16
|
-
}
|
17
|
-
|
18
|
-
def initialize api_hash
|
19
|
-
@api_hash = api_hash
|
20
|
-
end
|
21
|
-
|
22
|
-
METHODS.each do |name, uri|
|
23
|
-
define_method(name) { RubyRedtail::Query.run("settings/#{uri}", @api_hash, "GET") }
|
24
|
-
end
|
25
|
-
|
26
|
-
METHODS_WITH_DELETE.each do |name, uri|
|
27
|
-
define_method(name) { |deleted=false| RubyRedtail::Query.run("settings/#{uri}?deleted=#{deleted ? 1 : 0}", @api_hash, "GET")}
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|