Class: Tag
- Inherits:
-
LogicalModel
- Object
- LogicalModel
- Tag
- Defined in:
- app/models/tag.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.account_tags(account_name) ⇒ Object
Returns all the tags associated with a given account.
- .batch_add(tags, contact_ids, account_name, params = {}) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'app/models/tag.rb', line 2 def name @name end |
Class Method Details
.account_tags(account_name) ⇒ Object
Returns all the tags associated with a given account
35 36 37 |
# File 'app/models/tag.rb', line 35 def self.(account_name) paginate(per_page: 999, account_name: account_name) end |
.batch_add(tags, contact_ids, account_name, params = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/models/tag.rb', line 39 def self.batch_add(, contact_ids, account_name, params = {}) params.merge!({ account_name: account_name, tags: , contact_ids: contact_ids }) params = self.merge_key(params) response = nil Timeout::timeout(self.timeout/1000) do response = Typhoeus::Request.post("#{url_protocol_prefix}#{self.host}/v0/accounts/#{account_name}/tags/batch_add", :params => params, :timeout => self.timeout) end if response.code == 201 || response.code == 202 log_ok(response) return true elsif response.code == 400 log_failed(response) ws_errors = ActiveSupport::JSON.decode(response.body)["errors"] ws_errors.each_key do |k| self.errors.add k, ws_errors[k] end return false else log_failed(response) return nil end rescue Timeout::Error self.class.logger.warn "timeout" return nil end |
Instance Method Details
#id ⇒ Object
25 26 27 |
# File 'app/models/tag.rb', line 25 def id self._id end |
#id=(id) ⇒ Object
29 30 31 |
# File 'app/models/tag.rb', line 29 def id= id self._id = id end |
#json_root ⇒ Object
17 18 19 |
# File 'app/models/tag.rb', line 17 def json_root :tag end |
#to_key ⇒ Object
21 22 23 |
# File 'app/models/tag.rb', line 21 def to_key [self._id] end |