agilecrm-wrapper 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f14032514351c664b52f1634b34d61988b25d619
4
- data.tar.gz: 19b893dcce34567703ef06169e115abb4197babd
3
+ metadata.gz: 9f8164dd410e9b3170832a19d196f36341392189
4
+ data.tar.gz: 796ffe45dc8617ac270eb481d3d967205415255f
5
5
  SHA512:
6
- metadata.gz: f3e86f04c2dcaca52e554fbda101009292379f38b7dfd29e15630a59f79d784308142e9b64ace9972b6cc75ace97dd8a7b0323c205cc3abab0645bd99c442da2
7
- data.tar.gz: 29407b1567e1d289e4eef857aa17f0d9583ec35f47c91bd493992a6ab2157ddf9cbdead9b89b51b0d444f5cefacd4235767d2effa2a9ddf7f3c47b68d9bbefec
6
+ metadata.gz: 83ccfe9651395b4d22e178d7cdcecaba597380cf6004e65d3e735d8e69566d060e785e6b2be1258bdd356c2fad758b5b11e91c7a12851b1ce9035ee6938841a3
7
+ data.tar.gz: 790244c1538b85d322466d6d39b5060e86c9592550c4cec600e5bce9c7b56c0511e2641c06d989eb99db68c77843b69c8a91523ec8ec7b2a311240fce9157640
data/.gitignore CHANGED
@@ -18,3 +18,4 @@ _yardoc
18
18
  doc/
19
19
  todo.txt
20
20
  agile.js
21
+ *.swp
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- agilecrm-wrapper (1.0.1)
4
+ agilecrm-wrapper (1.0.2)
5
5
  faraday (~> 0.9)
6
6
  faraday_middleware
7
7
  hashie
@@ -23,8 +23,8 @@ GEM
23
23
  multipart-post (>= 1.2, < 3)
24
24
  faraday_middleware (0.9.1)
25
25
  faraday (>= 0.7.4, < 0.10)
26
- hashie (3.3.1)
27
- json (1.8.1)
26
+ hashie (3.3.2)
27
+ json (1.8.2)
28
28
  method_source (0.8.2)
29
29
  multipart-post (2.0.0)
30
30
  parser (2.2.0.pre.5)
data/LICENSE CHANGED
@@ -1,7 +1,5 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014 Cogmation Robotics Inc.
4
-
5
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
4
  of this software and associated documentation files (the "Software"), to deal
7
5
  in the Software without restriction, including without limitation the rights
@@ -41,7 +41,11 @@ module AgileCRMWrapper
41
41
 
42
42
  def create(options = {})
43
43
  payload = parse_contact_fields(options)
44
- AgileCRMWrapper.connection.post('contacts', payload)
44
+ response = AgileCRMWrapper.connection.post('contacts', payload)
45
+ if response && response.status == 200
46
+ contact = new(response.body)
47
+ end
48
+ contact
45
49
  end
46
50
 
47
51
  def delete(arg)
@@ -98,8 +102,12 @@ module AgileCRMWrapper
98
102
 
99
103
  def get_property(property_name)
100
104
  return unless respond_to?(:properties)
101
- prop = properties.select { |a| a['name'] == property_name.to_s }
102
- OpenStruct.new(*prop).value
105
+ arr = properties.select { |a| a['name'] == property_name.to_s }
106
+ if arr.length > 1
107
+ arr.map {|i| i['value'] }
108
+ else
109
+ arr.first['value'] if arr.first
110
+ end
103
111
  end
104
112
 
105
113
  private
@@ -1,3 +1,3 @@
1
1
  module AgileCRMWrapper
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -63,7 +63,7 @@ describe AgileCRMWrapper::Contact do
63
63
  )
64
64
  end
65
65
 
66
- its(:status) { should eq 201 }
66
+ its(:class) { should eq AgileCRMWrapper::Contact }
67
67
  end
68
68
 
69
69
  describe '#notes' do
@@ -97,6 +97,12 @@ describe AgileCRMWrapper::Contact do
97
97
  expect(contact.get_property('nil-propety')).to be_nil
98
98
  end
99
99
  end
100
+
101
+ context 'two properties share the same name' do
102
+ it 'returns an array' do
103
+ expect(contact.get_property('phone_number').class).to eq(Array)
104
+ end
105
+ end
100
106
  end
101
107
 
102
108
  describe '#destroy' do
@@ -37,9 +37,17 @@
37
37
  "type": "CUSTOM",
38
38
  "name": "custom_field",
39
39
  "value": "Im a custom field!"
40
+ }, {
41
+ "type": "CUSTOM",
42
+ "name": "phone_number",
43
+ "value": "1231111111"
44
+ }, {
45
+ "type": "CUSTOM",
46
+ "name": "phone_number",
47
+ "value": "1232222222"
40
48
  }],
41
49
  "campaignStatus": [],
42
50
  "entity_type": "contact_entity",
43
51
  "unsubscribeStatus": [],
44
52
  "emailBounceStatus": []
45
- }
53
+ }
@@ -31,7 +31,7 @@ class FakeAgileCRM < Sinatra::Base
31
31
  end
32
32
 
33
33
  post '/dev/api/contacts' do
34
- json_response 201, 'contacts', 'create_contact'
34
+ json_response 200, 'contacts', 'create_contact'
35
35
  end
36
36
 
37
37
  post '/dev/api/contacts/bulk/tags' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agilecrm-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-15 00:00:00.000000000 Z
11
+ date: 2015-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday