sukremore 0.0.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 +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +1 -0
- data/lib/sukremore.rb +12 -0
- data/lib/sukremore/client.rb +182 -0
- data/lib/sukremore/modules/account.rb +117 -0
- data/lib/sukremore/modules/base.rb +11 -0
- data/lib/sukremore/modules/email.rb +47 -0
- data/lib/sukremore/modules/lead.rb +56 -0
- data/lib/sukremore/version.rb +3 -0
- data/sukremore.gemspec +23 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3cea609e9f45e9730ed3c33846b0933e882113dd
|
4
|
+
data.tar.gz: 4e65b678654e33b8637e4beb0fa7ac3f97cef544
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2b1194857bc56ef33ca996976571507a2c8d8d49df9c66c69b1fcc85c33e5e313b5b55a7a6f09d4b254914e22e12f0b3fe4d2b01c5ecf5371943bb840eb85098
|
7
|
+
data.tar.gz: c2c965b26cb127d727a425eddd84cd3516f59c5bc297521116fc3af7c75b36ccc81f1860edfe24c3895b02447fcb9bb60f0a4f869df451c2469b00f950a4bfd5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Oliver HV
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
sukremore
|
2
|
+
=========
|
3
|
+
|
4
|
+
# Sukremore
|
5
|
+
|
6
|
+
Client for the Rest SugarCRM webservice.
|
7
|
+
In this very first version only limited access to Account and Contact models is implemented.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'sukremore'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install sukremore
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
Documentation for the WS's API can be found at the CRM itself: http://crm.coditramuntana.com/service/v2/rest.php
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/sukremore.rb
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'json'
|
4
|
+
require 'sukremore/modules/base'
|
5
|
+
require 'sukremore/modules/account'
|
6
|
+
require 'sukremore/modules/email'
|
7
|
+
require 'sukremore/modules/lead'
|
8
|
+
|
9
|
+
#
|
10
|
+
# To use the Sukremore::Client the first thing to do is call user_auth so that
|
11
|
+
# the client authenticates with SugarCRM. Once authenticated, the rest of the calls
|
12
|
+
# may be performed without authenticating again.
|
13
|
+
#
|
14
|
+
# For more documentation on the SugarCRM Rest API check:
|
15
|
+
# http://xxx-crm.coditramuntana.com/service/v2/rest.php
|
16
|
+
#
|
17
|
+
module Sukremore
|
18
|
+
class Client
|
19
|
+
include Sukremore
|
20
|
+
attr_reader :endpoint_name
|
21
|
+
|
22
|
+
def initialize url, config
|
23
|
+
@url= url
|
24
|
+
@config= config
|
25
|
+
@endpoint_name= @config['endpoint_name'] || 'Web'
|
26
|
+
end
|
27
|
+
|
28
|
+
# Authenticates with the given SugarCRM
|
29
|
+
# Returns true if succeeded, false otherwise.
|
30
|
+
def user_auth
|
31
|
+
sugar_resp = sugar_do_rest_call(
|
32
|
+
@url,
|
33
|
+
'login',
|
34
|
+
:user_auth => {:user_name => @config['username'], :password => Digest::MD5.hexdigest(@config['password']), :version => @config['api_version']}
|
35
|
+
)
|
36
|
+
@session_id = sugar_resp['id']
|
37
|
+
@logged_user= find_user_by_name @config['username']
|
38
|
+
raise "Error performing login to SugarCRM, returned session_id is nil" if @session_id.blank?
|
39
|
+
end
|
40
|
+
|
41
|
+
def from_leads
|
42
|
+
Modules::Lead.new(self)
|
43
|
+
end
|
44
|
+
|
45
|
+
def from_accounts
|
46
|
+
Modules::Account.new(self)
|
47
|
+
end
|
48
|
+
|
49
|
+
def from_emails
|
50
|
+
Modules::Email.new(self)
|
51
|
+
end
|
52
|
+
|
53
|
+
# GET
|
54
|
+
# Get the first user named with the name arg.
|
55
|
+
# Returns nil if not found.
|
56
|
+
#
|
57
|
+
def find_user_by_name name
|
58
|
+
users= find_users_by_name name
|
59
|
+
users.first
|
60
|
+
end
|
61
|
+
|
62
|
+
# GET
|
63
|
+
# Get the users named with the name arg.
|
64
|
+
#
|
65
|
+
def find_users_by_name name
|
66
|
+
sugar_resp = sugar_do_rest_call(
|
67
|
+
@url,
|
68
|
+
'get_entry_list',
|
69
|
+
{ :session => @session_id,
|
70
|
+
:module_name => "Users",
|
71
|
+
:query => "user_name='#{name}'",#"email_address IN ('#{email}')", # the SQL WHERE clause without the word “where”.
|
72
|
+
:order_by => '', # the SQL ORDER BY clause without the phrase “order by”.
|
73
|
+
:offset => '0', # the record offset from which to start.
|
74
|
+
:select_fields => ['email_address'],
|
75
|
+
:max_results => '1',
|
76
|
+
#:link_name_to_fields_array => [{:name => 'id'}, {:value => ['id', 'name']}],
|
77
|
+
:deleted => 0, # exclude deleted records
|
78
|
+
:favorites => false # if only records marked as favorites should be returned.
|
79
|
+
}
|
80
|
+
)
|
81
|
+
return sugar_resp["entry_list"]
|
82
|
+
end
|
83
|
+
|
84
|
+
# SET ENTRY
|
85
|
+
# Creates or updates an entity
|
86
|
+
def set_entry module_name, entry
|
87
|
+
names_values = []
|
88
|
+
names_values << {:name => "id", :value => entry[:id]} if entry[:id].present?
|
89
|
+
names_values << {:name => "date_entered", :value => Time.now} if entry[:id].blank?
|
90
|
+
names_values << {:name => "created_by", :value => @logged_user['id']} if entry[:id].blank?
|
91
|
+
names_values << {:name => "date_modified", :value => Time.now}
|
92
|
+
names_values << {:name => "modified_user_id", :value => @logged_user['id']}
|
93
|
+
entry.entries.each do |field, value|
|
94
|
+
names_values << {:name => field, :value => value}
|
95
|
+
end
|
96
|
+
|
97
|
+
sugar_resp= sugar_do_rest_call(
|
98
|
+
@url,
|
99
|
+
'set_entry',
|
100
|
+
{
|
101
|
+
:session => @session_id,
|
102
|
+
:module_name => module_name,
|
103
|
+
:name_value_list => names_values
|
104
|
+
}
|
105
|
+
)
|
106
|
+
sugar_resp['id']
|
107
|
+
end
|
108
|
+
|
109
|
+
def get_entry_list module_name, params={}
|
110
|
+
sugar_rs= sugar_do_rest_call(
|
111
|
+
@url,
|
112
|
+
'get_entry_list',
|
113
|
+
{ :session => @session_id,
|
114
|
+
:module_name => module_name,
|
115
|
+
}.merge(params)
|
116
|
+
)
|
117
|
+
sugar_rs
|
118
|
+
end
|
119
|
+
# SET
|
120
|
+
# Insert relation between modules
|
121
|
+
def set_relationship src_module_name, src_module_id, link_field_name, related_ids
|
122
|
+
sugar_resp = sugar_do_rest_call(
|
123
|
+
@url,
|
124
|
+
'set_relationship',
|
125
|
+
{
|
126
|
+
:session => @session_id,
|
127
|
+
:module_name => src_module_name,
|
128
|
+
:module_id => src_module_id,
|
129
|
+
:link_field_name => link_field_name,
|
130
|
+
:related_ids => related_ids,
|
131
|
+
}
|
132
|
+
)
|
133
|
+
sugar_resp["id"]
|
134
|
+
end
|
135
|
+
|
136
|
+
#
|
137
|
+
# Converts a Sugar Entity into a simple Ruby hash.
|
138
|
+
#
|
139
|
+
def import_sugar_entity sugar_entity
|
140
|
+
entity= {}
|
141
|
+
sugar_entity['name_value_list'].values.each do |field|
|
142
|
+
entity[field['name']]= field['value']
|
143
|
+
end
|
144
|
+
entity
|
145
|
+
end
|
146
|
+
#--------------------------------------------------------------------------
|
147
|
+
private
|
148
|
+
#--------------------------------------------------------------------------
|
149
|
+
|
150
|
+
#
|
151
|
+
# Do a POST to SugarCRM
|
152
|
+
#
|
153
|
+
# NOTE: Order of +params+ IS important.
|
154
|
+
#
|
155
|
+
#
|
156
|
+
def sugar_do_rest_call(url, method, params = {})
|
157
|
+
uri = URI(url)
|
158
|
+
http = Net::HTTP.new uri.host, uri.port
|
159
|
+
http.open_timeout = 30
|
160
|
+
# Uncoment this two lines for use SSL
|
161
|
+
# http.use_ssl = true
|
162
|
+
# http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
163
|
+
|
164
|
+
json_params= params.to_json
|
165
|
+
logger.debug "rest_call request method: #{method} params:#{json_params}"
|
166
|
+
post_data = {
|
167
|
+
:method => method,
|
168
|
+
:input_type => 'JSON',
|
169
|
+
:response_type => 'JSON',
|
170
|
+
:rest_data => json_params,
|
171
|
+
}
|
172
|
+
http_resp = Net::HTTP.post_form(uri, post_data)
|
173
|
+
logger.debug "rest_call response:::#{http_resp}=#{http_resp.body}"
|
174
|
+
json_rs= JSON.parse(http_resp.body)
|
175
|
+
if json_rs['number'] == 11
|
176
|
+
# 11=> Invalid Session ID
|
177
|
+
raise http_respt.body
|
178
|
+
end
|
179
|
+
json_rs
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
#
|
2
|
+
# Account Module fields
|
3
|
+
# ---------------
|
4
|
+
# assigned_user_name
|
5
|
+
# modified_by_name
|
6
|
+
# created_by_name
|
7
|
+
# id
|
8
|
+
# name
|
9
|
+
# date_entered
|
10
|
+
# date_modified
|
11
|
+
# modified_user_id
|
12
|
+
# created_by
|
13
|
+
# description
|
14
|
+
# deleted
|
15
|
+
# assigned_user_id
|
16
|
+
# account_type
|
17
|
+
# industry
|
18
|
+
# annual_revenue
|
19
|
+
# phone_fax
|
20
|
+
# billing_address_street
|
21
|
+
# billing_address_city
|
22
|
+
# billing_address_state
|
23
|
+
# billing_address_postalcode
|
24
|
+
# billing_address_country
|
25
|
+
# rating
|
26
|
+
# phone_office
|
27
|
+
# phone_alternate
|
28
|
+
# website
|
29
|
+
# ownership
|
30
|
+
# employees
|
31
|
+
# ticker_symbol
|
32
|
+
# shipping_address_street
|
33
|
+
# shipping_address_city
|
34
|
+
# shipping_address_state
|
35
|
+
# shipping_address_postalcode
|
36
|
+
# shipping_address_country
|
37
|
+
# email1
|
38
|
+
# parent_id
|
39
|
+
# sic_code
|
40
|
+
# parent_name
|
41
|
+
# campaign_id
|
42
|
+
# campaign_name
|
43
|
+
# cifra_negocio_c
|
44
|
+
# interes_en_prod_c
|
45
|
+
# currency_id
|
46
|
+
#
|
47
|
+
module Sukremore
|
48
|
+
module Modules
|
49
|
+
class Account < Base
|
50
|
+
MODULE_NAME= 'Accounts'
|
51
|
+
#
|
52
|
+
# Do a rest call to a SugarCRM Account by the given query
|
53
|
+
#
|
54
|
+
def sugar_get_account_by_query sql_cond= nil
|
55
|
+
raise "session_id[#{@session_id}]/url[#{@url}] can't be nil" if @session_id == nil || @url == nil
|
56
|
+
|
57
|
+
sugar_resp = @client.get_entry_list(MODULE_NAME, {
|
58
|
+
:query => sql_cond, # the SQL WHERE clause without the word “where”.
|
59
|
+
:order_by => '', # the SQL ORDER BY clause without the phrase “order by”.
|
60
|
+
:offset => '0', # the record offset from which to start.
|
61
|
+
:select_fields => ['id', 'nif_code_c', 'name', 'billing_address_street', 'phone_office_label', 'billing_address_city', 'billing_address_state', 'billing_address_postalcode', 'billing_address_country', 'website', 'email_adresse_c'],
|
62
|
+
:max_results => '10',
|
63
|
+
#:link_name_to_fields_array => [{:name => 'id'}, {:value => ['id', 'name']}],
|
64
|
+
:deleted => 0, # exclude deleted records
|
65
|
+
:favorites => false # if only records marked as favorites should be returned.
|
66
|
+
})
|
67
|
+
|
68
|
+
return sugar_resp
|
69
|
+
end
|
70
|
+
|
71
|
+
def create fields
|
72
|
+
@client.set_entry MODULE_NAME, fields
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# Opts:
|
77
|
+
# - +select_fields+ defaults to all.
|
78
|
+
#
|
79
|
+
def find_all_accounts opts={}
|
80
|
+
pending_pages= true
|
81
|
+
accounts= []
|
82
|
+
offset= 0
|
83
|
+
sugar_resp= nil
|
84
|
+
while pending_pages
|
85
|
+
offset= sugar_resp['next_offset'] unless sugar_resp.nil?
|
86
|
+
opts[:offset]= offset
|
87
|
+
sugar_resp= query_accounts(opts)
|
88
|
+
pending_pages= (sugar_resp['result_count'] > 0) && (sugar_resp['result_count'] != sugar_resp['next_offset'])
|
89
|
+
sugar_resp['entry_list'].each do |sa|
|
90
|
+
accounts << @client.import_sugar_entity(sa)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
accounts
|
94
|
+
end
|
95
|
+
|
96
|
+
def query_accounts opts={}
|
97
|
+
# Order of parameters IS important
|
98
|
+
params= {}
|
99
|
+
params[:query]= opts[:query] unless opts[:query].nil?
|
100
|
+
## the record offset from which to start.
|
101
|
+
params[:offset]= opts[:offset].nil? ? 0 : opts[:offset]
|
102
|
+
# exclude deleted records
|
103
|
+
params[:deleted]= opts[:deleted].nil? ? 0 : opts[:deleted]
|
104
|
+
params[:select_fields]= opts[:select_fields] unless opts[:select_fields].nil?
|
105
|
+
params[:offset]= opts[:offset] unless opts[:offset].nil?
|
106
|
+
sugar_resp = @client.get_entry_list(MODULE_NAME, params)
|
107
|
+
|
108
|
+
return sugar_resp
|
109
|
+
end
|
110
|
+
|
111
|
+
#-----------------------------------------------------------
|
112
|
+
private
|
113
|
+
#-----------------------------------------------------------
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Sukremore
|
2
|
+
module Modules
|
3
|
+
class Email < Base
|
4
|
+
MODULE_NAME= 'EmailAddresses'
|
5
|
+
# GET --------------------
|
6
|
+
# Returns the ID for the given email if it exists, false otherwise.
|
7
|
+
def email_id? email
|
8
|
+
raise "email can't be nil" if email == nil
|
9
|
+
sugar_resp = @client.get_entry_list(MODULE_NAME, {
|
10
|
+
:query => 'email_address=\''+ email +'\'',#"email_address IN ('#{email}')", # the SQL WHERE clause without the word “where”.
|
11
|
+
:order_by => '', # the SQL ORDER BY clause without the phrase “order by”.
|
12
|
+
:offset => '0', # the record offset from which to start.
|
13
|
+
:select_fields => ['email_address'],
|
14
|
+
:max_results => '1',
|
15
|
+
#:link_name_to_fields_array => [{:name => 'id'}, {:value => ['id', 'name']}],
|
16
|
+
:deleted => 0, # exclude deleted records
|
17
|
+
:favorites => false # if only records marked as favorites should be returned.
|
18
|
+
}
|
19
|
+
)
|
20
|
+
if sugar_resp['entry_list'].any?
|
21
|
+
sugar_resp['entry_list'][0]['id']
|
22
|
+
else
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# SET
|
28
|
+
# insert email.
|
29
|
+
# Returns the email id on success, otherwise returns nil.
|
30
|
+
def insert_email email
|
31
|
+
raise "really? add new a new empty account?" if email.nil? or email.empty?
|
32
|
+
|
33
|
+
email_params = {
|
34
|
+
email_address: email,
|
35
|
+
email_address_caps: email.upcase,
|
36
|
+
invalid_email: false,
|
37
|
+
opt_out: false,
|
38
|
+
created_at: Time.now,
|
39
|
+
updated: Time.now
|
40
|
+
}
|
41
|
+
|
42
|
+
@client.set_entry Email::MODULE_NAME, email_params
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Sukremore
|
2
|
+
module Modules
|
3
|
+
class Lead < Base
|
4
|
+
MODULE_NAME= 'Leads'
|
5
|
+
|
6
|
+
# Inserts a new lead into the SugarCRM.
|
7
|
+
#
|
8
|
+
#
|
9
|
+
# Accepted params (symbol keys) are:
|
10
|
+
# - :lead_id <- may be null on create.
|
11
|
+
# - :lead_desc
|
12
|
+
# - :name
|
13
|
+
# - :email1
|
14
|
+
#
|
15
|
+
# Returns the id of the lead on success, otherwise returns nil.
|
16
|
+
def set_lead lead={}
|
17
|
+
raise "really? add new a new empty lead?" if lead.empty?
|
18
|
+
|
19
|
+
if lead[:description].nil? or lead[:description].empty?
|
20
|
+
lead[:description]= "Lead generated from #{@client.endpoint_name}-> [(#{Time.now})- #{lead[:text]}]"
|
21
|
+
end
|
22
|
+
if lead[:lead_source].nil? || lead[:lead_source].empty?
|
23
|
+
lead[:lead_source]= @client.endpoint_name
|
24
|
+
end
|
25
|
+
if lead[:status].nil? || lead[:status].empty?
|
26
|
+
lead[:lead_source]= 'New'
|
27
|
+
end
|
28
|
+
|
29
|
+
@client.set_entry Lead::MODULE_NAME, lead
|
30
|
+
end
|
31
|
+
|
32
|
+
# GET lead id and desc searching by email
|
33
|
+
def get_lead_by_email email_id
|
34
|
+
query = %Q{leads.id in
|
35
|
+
(select email_addr_bean_rel.bean_id
|
36
|
+
from email_addr_bean_rel
|
37
|
+
where email_addr_bean_rel.bean_module = 'Leads'
|
38
|
+
and email_addr_bean_rel.email_address_id = '#{email_id}'
|
39
|
+
)
|
40
|
+
}
|
41
|
+
sugar_resp = @client.get_entry_list(MODULE_NAME, {
|
42
|
+
:query => query,
|
43
|
+
:order_by => '', # the SQL ORDER BY clause without the phrase “order by”.
|
44
|
+
:offset => '0', # the record offset from which to start.
|
45
|
+
:select_fields => ['id', 'description'],
|
46
|
+
:max_results => '1',
|
47
|
+
:deleted => 0, # exclude deleted records
|
48
|
+
:favorites => false # if only records marked as favorites should be returned.
|
49
|
+
})
|
50
|
+
return {:lead_id => nil, :lead_desc => ""} if sugar_resp["entry_list"].length == 0
|
51
|
+
{:lead_id => sugar_resp["entry_list"][0]["id"], :lead_desc => sugar_resp["entry_list"][0]["name_value_list"]["description"]["value"]}
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/sukremore.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sukremore/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sukremore"
|
8
|
+
spec.version = Sukremore::VERSION
|
9
|
+
spec.authors = ["Oliver HV"]
|
10
|
+
spec.email = ["oliver.hv@coditramuntana.com"]
|
11
|
+
spec.description = %q{Client for the Rest SugarCRM webservice.}
|
12
|
+
spec.summary = %q{In this very first version only limited access to Account, Email and Lead models is implemented.}
|
13
|
+
spec.homepage = "http://www.coditramuntana.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sukremore
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oliver HV
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Client for the Rest SugarCRM webservice.
|
42
|
+
email:
|
43
|
+
- oliver.hv@coditramuntana.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/sukremore.rb
|
55
|
+
- lib/sukremore/client.rb
|
56
|
+
- lib/sukremore/modules/account.rb
|
57
|
+
- lib/sukremore/modules/base.rb
|
58
|
+
- lib/sukremore/modules/email.rb
|
59
|
+
- lib/sukremore/modules/lead.rb
|
60
|
+
- lib/sukremore/version.rb
|
61
|
+
- sukremore.gemspec
|
62
|
+
homepage: http://www.coditramuntana.com
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.2.2
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: In this very first version only limited access to Account, Email and Lead
|
86
|
+
models is implemented.
|
87
|
+
test_files: []
|