contacts_client 0.0.17 → 0.0.18

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.
@@ -0,0 +1,48 @@
1
+ class ContactAttribute
2
+ module CustomKeys
3
+
4
+ # Get CustomAttribute names
5
+ #
6
+ # @param options [ Hash ]
7
+ #
8
+ # @example
9
+ # ContactAttribute.async_custom_keys(:page => params[:page]){|i| result = i}
10
+ def async_custom_keys(options={})
11
+ options = self.merge_key(options)
12
+
13
+ request = Typhoeus::Request.new("#{resource_uri}/custom_keys", params: options)
14
+ request.on_complete do |response|
15
+ if response.code >= 200 && response.code < 400
16
+ log_ok(response)
17
+
18
+ parsed_response = ActiveSupport::JSON.decode(response.body)
19
+ yield parsed_response['collection']
20
+ else
21
+ log_failed(response)
22
+ end
23
+ end
24
+ self.hydra.queue(request)
25
+ end
26
+
27
+ ##
28
+ # Get CustomAttribute names
29
+ # @see async_custom_keys
30
+ def custom_keys(options={})
31
+ result = nil
32
+ self.retries.times do
33
+ begin
34
+ async_custom_keys(options){|i| result = i}
35
+ Timeout::timeout(self.timeout/1000) do
36
+ self.hydra.run
37
+ end
38
+ break unless result.nil?
39
+ rescue Timeout::Error
40
+ self.logger.warn("timeout")
41
+ result = nil
42
+ end
43
+ end
44
+ result
45
+ end
46
+
47
+ end
48
+ end
@@ -1,17 +1,26 @@
1
1
  class ContactAttribute < LogicalModel
2
2
 
3
+ # defines ContactAttribute.custom_keys and .async_custom_keys
4
+ extend ContactAttribute::CustomKeys
5
+
3
6
  AVAILABLE_TYPES = %w(telephone email identification address date_attribute custom_attribute social_network_id)
4
7
 
5
8
  attr_accessor :public, :primary
6
9
 
7
- self.attribute_keys = [:_id, :_type, :value, :public, :primary, :contact_id, :account_name]
10
+ attribute :_id
11
+ attribute :_type
12
+ attribute :value
13
+ attribute :public
14
+ attribute :primary
15
+ attribute :account_name
16
+
17
+ belongs_to :contact, class: 'PadmaContact'
18
+
19
+ use_hydra Contacts::HYDRA
20
+ set_resource_url Contacts::HOST, "/v0/contact_attributes"
21
+ set_api_key 'app_key', Contacts::API_KEY
8
22
 
9
- self.hydra = Contacts::HYDRA
10
- self.resource_path = "/v0/contact_attributes"
11
- self.use_api_key = true
12
- self.api_key_name = "app_key"
13
- self.api_key = Contacts::API_KEY
14
- self.host = Contacts::HOST
23
+ validates :value, :presence => true, :unless => proc { self.is_a? DateAttribute }
15
24
 
16
25
  def new_record?
17
26
  self._id.blank?
@@ -21,8 +30,6 @@ class ContactAttribute < LogicalModel
21
30
  false
22
31
  end
23
32
 
24
- validates :value, :presence => true, :unless => proc { self.is_a? DateAttribute }
25
-
26
33
  def json_root
27
34
  :contact_attribute
28
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contacts_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-23 00:00:00.000000000 Z
12
+ date: 2013-08-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 0.5.0
37
+ version: 0.5.8
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 0.5.0
45
+ version: 0.5.8
46
46
  description: This is client library for padma-Contacts-ws
47
47
  email:
48
48
  - dwaynemac@gmail.com
@@ -62,6 +62,7 @@ files:
62
62
  - app/models/padma_contact.rb
63
63
  - app/models/contacts_merge.rb
64
64
  - app/models/attachment.rb
65
+ - app/models/contact_attribute/custom_keys.rb
65
66
  - app/models/contact_attribute.rb
66
67
  - app/models/avatar.rb
67
68
  - lib/contacts_client.rb