capsule_crm 0.10.2 → 0.10.3

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: fe0200eaa38f56d70ebe6aac7a0753b881cd57d5
4
- data.tar.gz: 3fddf33fe50156ea8949b456dd072544e01d2b59
3
+ metadata.gz: 6215127ba0a534da3f66ee07f81e52eb44a1b94f
4
+ data.tar.gz: 06fcb9fd7bceb43377a8dc31fb7d5a3b3330aff4
5
5
  SHA512:
6
- metadata.gz: 186db3ab34a48f0417c7a50e31b7f77952a12a39c7e1053c1889c9a0e83b3299308899d308d8357e4fcd6dafdb23b5092267a98f90df01ef9bf95f06398bfc90
7
- data.tar.gz: 0def9e908692cad017f50a03c8d8d88abdc9362e79ae7f1f4c5fa3d2413e18ffc0a019ad9c6b621b2675dbb48e22e8a124116125274fa353b18c83fb2c11484e
6
+ metadata.gz: 548e38de32cbb6759975a5802974ef94196fdbfaa809d02b01d2e1b1bb4401afb94271ebdf979c7ac3a147b68718c33ae0359511ea7770c8118805c8ae854a33
7
+ data.tar.gz: edda8a8f701984893d6a3b1cd56ee22981d59dfe0ccff4614146937235c7d310656b1af904565b9685439e15df77d32dbc5bba8c47ad74a2d5c174c533e121b3
@@ -8,6 +8,7 @@ module CapsuleCRM
8
8
  #
9
9
  # Returns a Hash from the JSON response
10
10
  def self.get(path, params = {})
11
+ preprocess_params(params)
11
12
  response = faraday.get(path, params) do |req|
12
13
  req.headers.update default_request_headers
13
14
  end
@@ -35,6 +36,18 @@ module CapsuleCRM
35
36
 
36
37
  private
37
38
 
39
+ def self.preprocess_params(params)
40
+ params.symbolize_keys!
41
+ if params_contains_lastmodified(params)
42
+ params[:lastmodified] = params[:lastmodified].strftime("%Y%m%dT%H%M%S")
43
+ end
44
+ end
45
+
46
+ def self.params_contains_lastmodified(params)
47
+ params.keys.include?(:lastmodified) &&
48
+ params[:lastmodified].respond_to?(:strftime)
49
+ end
50
+
38
51
  # TODO clean this shit up
39
52
  def self.process_post_response(response)
40
53
  if response.success?
@@ -9,10 +9,9 @@ class CapsuleCRM::Party
9
9
  has_many :tasks, class_name: 'CapsuleCRM::Task', source: :party
10
10
 
11
11
  def self.all(options = {})
12
- process_options(options)
13
- attributes = CapsuleCRM::Connection.get('/api/party', options)
14
-
15
- init_collection(attributes['parties'])
12
+ init_collection(
13
+ CapsuleCRM::Connection.get('/api/party', options)['parties']
14
+ )
16
15
  end
17
16
 
18
17
  def self.find(id)
@@ -39,11 +38,4 @@ class CapsuleCRM::Party
39
38
  { person: 'CapsuleCRM::Person', organisation: 'CapsuleCRM::Organization' }.
40
39
  stringify_keys
41
40
  end
42
-
43
- def self.process_options(options)
44
- if options[:lastmodified] && options[:lastmodified].respond_to?(:strftime)
45
- options[:lastmodified] = options[:lastmodified].
46
- strftime("%Y%m%dT%H%M%SZ")
47
- end
48
- end
49
41
  end
@@ -1,3 +1,3 @@
1
1
  module CapsuleCrm
2
- VERSION = '0.10.2'
2
+ VERSION = '0.10.3'
3
3
  end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe CapsuleCRM::Connection do
4
+ before { configure }
5
+
6
+ describe '.get' do
7
+ context 'when lastmodified is in the supplied params' do
8
+ before do
9
+ stub_request(:get, /\/api\/v1\/foo/).to_return(body: '{}')
10
+ CapsuleCRM::Connection.
11
+ get('/api/v1/foo', lastmodified: Time.new(2013, 10, 1, 13, 31, 56))
12
+ end
13
+
14
+ it 'should make sure that the lastmodified is formatted in YYYYMMDDTHHMMSS' do
15
+ WebMock.should have_requested(
16
+ :get, 'https://1234:@company.capsulecrm.com/api/v1/foo'
17
+ ).with(query: { lastmodified: "20131001T133156" })
18
+ end
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capsule_crm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Beedle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-27 00:00:00.000000000 Z
11
+ date: 2013-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -299,6 +299,7 @@ files:
299
299
  - spec/lib/capsule_crm/associations/has_many_proxy_spec.rb
300
300
  - spec/lib/capsule_crm/associations/has_many_spec.rb
301
301
  - spec/lib/capsule_crm/case_spec.rb
302
+ - spec/lib/capsule_crm/connection_spec.rb
302
303
  - spec/lib/capsule_crm/contacts_spec.rb
303
304
  - spec/lib/capsule_crm/country_spec.rb
304
305
  - spec/lib/capsule_crm/currency_spec.rb
@@ -378,6 +379,7 @@ test_files:
378
379
  - spec/lib/capsule_crm/associations/has_many_proxy_spec.rb
379
380
  - spec/lib/capsule_crm/associations/has_many_spec.rb
380
381
  - spec/lib/capsule_crm/case_spec.rb
382
+ - spec/lib/capsule_crm/connection_spec.rb
381
383
  - spec/lib/capsule_crm/contacts_spec.rb
382
384
  - spec/lib/capsule_crm/country_spec.rb
383
385
  - spec/lib/capsule_crm/currency_spec.rb