solve360 0.0.5 → 0.0.7
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.
- data/README.markdown +6 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/solve360/company.rb +2 -1
- data/lib/solve360/contact.rb +5 -1
- data/lib/solve360/item.rb +35 -5
- data/spec/fixtures/contacts/find-all.json +2 -0
- data/spec/solve360/item_spec.rb +16 -0
- metadata +3 -2
data/README.markdown
CHANGED
@@ -57,6 +57,12 @@ and then used:
|
|
57
57
|
|
58
58
|
### Finding
|
59
59
|
|
60
|
+
You can pull all records with:
|
61
|
+
|
62
|
+
contacts = Solve360::Contact.find(:all)
|
63
|
+
|
64
|
+
**Please Note:** It's not yet possible to pass filter conditions to find(:all).
|
65
|
+
|
60
66
|
You can find by the ID of a record on the CRM:
|
61
67
|
|
62
68
|
contact = Solve360::Contact.find(12345)
|
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ begin
|
|
15
15
|
gem.add_dependency("httparty", ">=0.4.5")
|
16
16
|
end
|
17
17
|
rescue LoadError
|
18
|
-
puts "Jeweler not available. Install it with:
|
18
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
19
19
|
end
|
20
20
|
|
21
21
|
Spec::Rake::SpecTask.new(:spec) do |spec|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/solve360/company.rb
CHANGED
data/lib/solve360/contact.rb
CHANGED
data/lib/solve360/item.rb
CHANGED
@@ -138,13 +138,29 @@ module Solve360
|
|
138
138
|
new_record
|
139
139
|
end
|
140
140
|
|
141
|
-
# Find
|
141
|
+
# Find records
|
142
142
|
#
|
143
|
-
# @param [Integer] id of the record on the CRM
|
143
|
+
# @param [Integer, Symbol] id of the record on the CRM or :all
|
144
144
|
def find(id)
|
145
|
+
if id == :all
|
146
|
+
find_all
|
147
|
+
else
|
148
|
+
find_one(id)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Find a single record
|
153
|
+
#
|
154
|
+
# @param [Integer] id of the record on the CRM
|
155
|
+
def find_one(id)
|
145
156
|
response = request(:get, "/#{resource_name}/#{id}")
|
146
|
-
|
147
|
-
|
157
|
+
construct_record_from_singular(response)
|
158
|
+
end
|
159
|
+
|
160
|
+
# Find all records
|
161
|
+
def find_all
|
162
|
+
response = request(:get, "/#{resource_name}/", "<request><layout>1</layout></request>")
|
163
|
+
construct_record_from_collection(response)
|
148
164
|
end
|
149
165
|
|
150
166
|
# Send an HTTP request
|
@@ -159,7 +175,7 @@ module Solve360
|
|
159
175
|
:basic_auth => {:username => Solve360::Config.config.username, :password => Solve360::Config.config.token})
|
160
176
|
end
|
161
177
|
|
162
|
-
def
|
178
|
+
def construct_record_from_singular(response)
|
163
179
|
item = response["response"]["item"]
|
164
180
|
item.symbolize_keys!
|
165
181
|
|
@@ -180,6 +196,20 @@ module Solve360
|
|
180
196
|
record
|
181
197
|
end
|
182
198
|
|
199
|
+
def construct_record_from_collection(response)
|
200
|
+
response["response"].collect do |item|
|
201
|
+
item = item[1]
|
202
|
+
if item.respond_to?(:keys)
|
203
|
+
attributes = {}
|
204
|
+
attributes[:id] = item["id"]
|
205
|
+
|
206
|
+
attributes[:fields] = map_api_fields(item)
|
207
|
+
|
208
|
+
record = new(attributes)
|
209
|
+
end
|
210
|
+
end.compact
|
211
|
+
end
|
212
|
+
|
183
213
|
def resource_name
|
184
214
|
self.name.to_s.demodulize.underscore.pluralize
|
185
215
|
end
|
@@ -0,0 +1,2 @@
|
|
1
|
+
{"response":{"id31507":{"company":"\n Exactratems Consulting, Inconactron Technology, Systectro\n ","businessphonemain":"(580) 648-9094","name":"Aaron Baileys","businessphonedirect":"(382) 853-8544","assignedto":"53936","businessaddress":"1710, 840 7th Ave. SW\n Calgary, Alberta","cellularphone":"(333) 828-4633","background":"\n Referred by David, hes built three other homes in the valley.\n ","homephone":"(333) 934-9392","lastname":"Baileys","id":"31507","viewed":"2009-06-23T00:50:35+00:00","businessemail":"support@workcompedge.com","flagged":"1","website":"www.clientsite.com","firstname":"Aaron","updated":"2009-06-18T21:53:24+00:00","jobtitle":"Maintenance Mechanic","businessfax":"(111) 222-3333","created":"2008-08-04T00:00:10+00:00"},"count":"21","id34943":{"company":"Acle","businessphonemain":"(407) 713-0145","name":"Aaron Grant","businessaddress":"4437, Grand Avenue\n Winter Park FL 32789\n US","lastname":"Grant","id":"34943","viewed":"2009-01-19T15:49:29+00:00","businessemail":"Aaron.E.Grant@spambob.com","flagged":null,"firstname":"Aaron","updated":"2008-08-31T18:41:42+00:00","jobtitle":"Design Drafter Cad/Cam","created":"2008-08-04T00:03:05+00:00"},"status":"success"}}
|
2
|
+
|
data/spec/solve360/item_spec.rb
CHANGED
@@ -195,4 +195,20 @@ describe "Adding a releated item" do
|
|
195
195
|
it "should become set after save" do
|
196
196
|
@contact.related_items.first["name"].should == "A New Company"
|
197
197
|
end
|
198
|
+
end
|
199
|
+
|
200
|
+
describe "Finding all records" do
|
201
|
+
before do
|
202
|
+
stub_http_response_with("contacts/find-all.json")
|
203
|
+
@contacts = Solve360::Contact.find(:all)
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should contain all contacts" do
|
207
|
+
puts @contacts.inspect
|
208
|
+
@contacts.size.should == 2
|
209
|
+
first = @contacts.first
|
210
|
+
first.class.should == Solve360::Contact
|
211
|
+
first.fields["First Name"].should == "Aaron"
|
212
|
+
first.fields["Last Name"].should == "Baileys"
|
213
|
+
end
|
198
214
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solve360
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Bartholomew
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-04 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- spec/api_settings.yml
|
64
64
|
- spec/api_settings.yml.sample
|
65
65
|
- spec/fixtures/contacts/create-success.json
|
66
|
+
- spec/fixtures/contacts/find-all.json
|
66
67
|
- spec/fixtures/contacts/find-company-success.json
|
67
68
|
- spec/fixtures/contacts/find-success.json
|
68
69
|
- spec/fixtures/contacts/index.json
|