riq 0.8.5 → 0.8.8

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: ed36a60cb8ed191a2a696cbb7f3346f0c2e0449a
4
- data.tar.gz: 303fe5f58418cfddbdc102e31b54d1ea429dfe6f
3
+ metadata.gz: 6930e740162006d865dff1417751857418282d91
4
+ data.tar.gz: 6d8149a2bec6a8a1220ba1314675703c5ce1a599
5
5
  SHA512:
6
- metadata.gz: d0a6866a3efb4476e3cb894db8749d7aec3a3710e59e9b057de5640ec313c74b6d3e27861c6735089a45564a8deb285b9c5db6583ae5f604aad6f633f187f892
7
- data.tar.gz: c2c9514f5517cc9fc87f7f1a14ca855399b1d23f3e2bbc089b122deca1a34e07072ca1b699a6686c76a6cc80db9a3fd80c38e12bca857f6079ee14d404d51557
6
+ metadata.gz: 51fcceea1524ec5d3430f89ef5914ec76c0880dec883b922d9d8fe8a53f5aa4fc55568c1bdd2413a4c0dc4bb915259d2e25e4cb4ca022060100e4cf876b4bcf3
7
+ data.tar.gz: 7d5a8ec9ae93455beebddd0a41abadbc6fdc371a53af672b37ea3aab3b567bdaaa6ab456dae5b8055831ef4bd09ffc92f30d4c9da9a7eccd52b56b251872cd63
data/Gemfile CHANGED
@@ -5,4 +5,4 @@ group :development do
5
5
  gem 'pry'
6
6
  end
7
7
 
8
- gem 'httparty'
8
+ gem 'httparty', '0.13.3'
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 RelateIQ
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,15 @@
1
+ # RelateIQ Ruby SDK
2
+
3
+ A full featured API interface for interacting with the [RelateIQ](https://relateiq.com) API.
4
+
5
+ ## Overview
6
+
7
+ <!--[![Gem Version](https://badge.fury.io/rb/riq.svg)](http://badge.fury.io/rb/riq)-->
8
+ [![Gem Version](https://img.shields.io/gem/v/riq.svg)](http://badge.fury.io/rb/riq)
9
+ <!--[![MIT license](http://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT)-->
10
+
11
+
12
+ ## Helpful Links
13
+
14
+ * [Full ruby docs](http://www.rubydoc.info/gems/riq)
15
+ * [Examples and API docs](https://api.relateiq.com/#/ruby)
data/lib/riq.rb CHANGED
@@ -1,3 +1,7 @@
1
1
  # Base file from which everything else is included
2
+ Dir[__dir__ + '/riq/*.rb'].each {|file| require file }
2
3
 
3
- Dir[__dir__ + '/riq/*.rb'].each {|file| require file }
4
+ # The namespace from which all magic springs
5
+ module RIQ
6
+ # Could fetch defaults or something here
7
+ end
@@ -1,6 +1,7 @@
1
1
  require_relative 'riq_obj'
2
2
 
3
3
  module RIQ
4
+ # Accounts represent companies (or other entities).
4
5
  class Account < RIQObject
5
6
  attr_accessor :name
6
7
  attr_accessor :field_values
@@ -71,7 +72,7 @@ module RIQ
71
72
  # Convenince method to create new Accounts
72
73
  # @param id [String, nil] create a blank Account object or
73
74
  # fetch an existing one by id.
74
- # @return [RIQ::Account]
75
+ # @return [Account]
75
76
  def account(id = nil)
76
77
  Account.new(id)
77
78
  end
@@ -1,12 +1,11 @@
1
1
  module RIQ
2
- # Manages caching and fetching for a certain type of child
2
+ # Manages caching and fetching for a certain type of child object.
3
3
  class BatchManager
4
+ # @return [Hash] current fetch options
4
5
  attr_reader :fetch_options
5
6
 
6
- # @param klass [RIQObject] The child class that's being fetched, such as {Account} or {ListItem}
7
+ # @param klass [RIQObject] The child class that's being fetched, such as {Account} or {List}
7
8
  # @param page_length [Integer] The number of items per page
8
- # @!macro [new] krass
9
- # is a $1
10
9
  def initialize(klass, page_length = 200, fetch_options: {})
11
10
  @klass = klass
12
11
  begin
@@ -23,6 +22,10 @@ module RIQ
23
22
  end
24
23
 
25
24
  # Iterator for each item in the manager. Pass a block to it!
25
+ # @example
26
+ # RIQ.lists.each do |l|
27
+ # puts l
28
+ # end
26
29
  def each(&blok)
27
30
  reset_cache
28
31
  loop do
@@ -35,12 +38,15 @@ module RIQ
35
38
  end
36
39
  end
37
40
 
38
- # @return [@macro klass]
41
+ # Returns the first child object, mainly used for testing
42
+ # @return [RIQObject]
39
43
  def first
40
44
  reset_cache
41
45
  fetch_page(0, 1).first
42
46
  end
43
47
 
48
+ # Set fetch options
49
+ # @param opts [Hash] Where values are either strings or arrays
44
50
  def fetch_options=(opts = {})
45
51
  reset_cache
46
52
  options = {}
@@ -56,7 +62,6 @@ module RIQ
56
62
  end
57
63
 
58
64
  private
59
-
60
65
  def next_item
61
66
  if @cache_index == @cache.size
62
67
  return nil if ![0, @page_length].include? @cache.size
@@ -124,6 +129,7 @@ module RIQ
124
129
  end
125
130
 
126
131
  # these used to be 2 methods, now they're one
132
+ # not that we ever seem to use them, but they're there
127
133
  def batch(objs, mode)
128
134
  return_objs = {}
129
135
  while objs.size > 0
@@ -1,7 +1,5 @@
1
1
  require 'httparty'
2
- require 'pry'
3
2
  require 'json'
4
-
5
3
  require_relative 'error'
6
4
 
7
5
  module RIQ
@@ -53,16 +51,15 @@ module RIQ
53
51
  request(endpoint, :delete, nil, options)
54
52
  end
55
53
 
56
- def fetch(endpoint = nil, options: {})
57
- # i'm not sure why this would return an empty object instead of raising a notfound
58
- # or really, why it exists at all
59
- # puts "fetching #{endpoint} with options #{options}"
60
- # begin
61
- get(endpoint, options: options)
62
- # rescue NotFoundError
63
- # {}
64
- # end
65
- end
54
+ # I'm not sure why this would return an empty object instead of raising a notfound
55
+ # or really, why it exists at all
56
+ # def fetch(endpoint = nil, options: {})
57
+ # begin
58
+ # get(endpoint, options: options)
59
+ # rescue NotFoundError
60
+ # {}
61
+ # end
62
+ # end
66
63
 
67
64
  private
68
65
 
@@ -101,7 +98,6 @@ module RIQ
101
98
  # @return [RIQObject] The result of the request
102
99
  def process_response(resp)
103
100
  # pp "processing #{resp}, code: #{resp.code}"
104
- # binding.pry
105
101
  if resp.code == 503
106
102
  raise NotImplementedError, 'This function is not currently supported by RelateIQ'
107
103
  elsif resp.code == 404
@@ -130,9 +126,7 @@ module RIQ
130
126
  # end
131
127
  end
132
128
 
133
- class << self
134
- # A singleton client for use by methods in Object.
135
- # Always use RIQ.client to retrieve the client object.
129
+ class << self
136
130
  # @param key [String] RelateIQ API key
137
131
  # @param secret [String] RelateIQ API secret
138
132
  # @return [RIQ] The module, in case you want it.
@@ -144,6 +138,8 @@ module RIQ
144
138
  self
145
139
  end
146
140
 
141
+ # Always use RIQ.client to retrieve the client object.
142
+ # @return [Client] The client object
147
143
  def client
148
144
  raise RIQError, 'Client not initialized' unless @@client
149
145
  @@client
@@ -1,15 +1,16 @@
1
1
  require_relative 'riq_obj'
2
2
 
3
3
  module RIQ
4
+ # Contacts represent people in an Organization’s address book.
4
5
  class Contact < RIQObject
5
6
  attr_accessor :properties
6
7
 
7
- # (see RIQObject#node)
8
+ # (see RIQObject#node)
8
9
  def node
9
10
  self.class.node(@id)
10
11
  end
11
12
 
12
- # (see RIQObject#node)
13
+ # (see RIQObject.node)
13
14
  def self.node(id = nil)
14
15
  "contacts/#{id}"
15
16
  end
@@ -131,7 +132,7 @@ module RIQ
131
132
  # Convenince method to create new Contacts
132
133
  # @param id [String, nil] create a blank Contact object or
133
134
  # fetch an existing one by id.
134
- # @return [RIQ::Contact]
135
+ # @return [Contact]
135
136
  def contact(id = nil)
136
137
  Contact.new(id)
137
138
  end
@@ -1,15 +1,17 @@
1
- # Base exception class for our errors
2
-
3
1
  module RIQ
2
+ # Base exception class for our errors.
4
3
  class RIQError < StandardError
5
4
  end
6
5
 
6
+ # Hasn't been implemented yet. Doesn't get used often.
7
7
  class NotImplementedError < RIQError
8
8
  end
9
9
 
10
+ # Raised when an objectid fetch doesn't return anything.
10
11
  class NotFoundError < RIQError
11
12
  end
12
13
 
14
+ # Main error that includes info about the request and what went wrong.
13
15
  class HTTPError < RIQError
14
16
  attr_accessor :code
15
17
  attr_accessor :message
@@ -46,6 +48,7 @@ module RIQ
46
48
  @response = resp
47
49
  end
48
50
 
51
+ # used to print the error nicely
49
52
  def to_s
50
53
  @message || super
51
54
  end
@@ -1,16 +1,74 @@
1
- # require 'set'
2
- # require 'json'
3
- # require_relative 'riq_base'
4
-
5
- # # Events.rb
6
- # # Events represent interactions involving a Contact associated with a List Item.
7
- # # Instead of appearing as new content in List columns, Events appear in a “Stream view”
8
- # # associated with the appropriate List Item. If the same Contact is associated
9
- # # with more than one List Item, then the Event will appear in all relevant Stream views.
10
- # # For more info visit https://api.relateiq.com/#/ruby
11
-
12
- # class Event < RIQBase
13
- # # Object Attributes
1
+ require_relative 'riq_obj'
2
+
3
+ module RIQ
4
+ # Events represent interactions involving a Contact associated with a List Item.
5
+ class Event < RIQObject
6
+ attr_accessor :subject
7
+ attr_accessor :body
8
+ # attr_reader :participant_ids
9
+
10
+ # (see RIQObject#node)
11
+ def node
12
+ self.class.node
13
+ end
14
+
15
+ # (see RIQObject#node)
16
+ def self.node
17
+ "events"
18
+ end
19
+
20
+ # (see RIQObject#data)
21
+ def data
22
+ {
23
+ subject: @subject,
24
+ body: @body,
25
+ participant_ids: @participant_ids
26
+ }
27
+ end
28
+
29
+ # @param type [Symbol] One of :email or :phone
30
+ # @param value [String] An email or phone number for the contact
31
+ def add_participant(type, value)
32
+ raise RIQError, 'Type must be :email or :phone' unless [:email, :phone].include?(type)
33
+ @participant_ids << {type: type, value: value}
34
+ end
35
+
36
+ # @return [Array] Immutable copy of participant_ids
37
+ def participant_ids
38
+ @participant_ids.dup
39
+ end
40
+
41
+ # @return [Hash] Success message, if successul.
42
+ def save
43
+ # there are no options to pass for event save
44
+ @client.put(node, payload, options: nil)
45
+ {status: 204, message: 'No Content'}
46
+ end
47
+
48
+ private
49
+ def init(obj = nil)
50
+ unless obj.nil?
51
+ @subject = obj['subject']
52
+ @body = obj['body']
53
+ @participant_ids = obj['participantIds']
54
+ else
55
+ @subject = nil
56
+ @body = nil
57
+ @participant_ids = []
58
+ end
59
+ self
60
+ end
61
+ end
62
+
63
+ class << self
64
+ # Convenience method to create new Events
65
+ # @return [Event]
66
+ def event
67
+ Event.new
68
+ end
69
+ end
70
+ end
71
+
14
72
  # @id = nil
15
73
  # @modifiedDate = nil
16
74
  # @participantIds = nil
@@ -1,7 +1,8 @@
1
- # require_relative 'riq_obj'
2
- # require_relative 'batch_manager'
1
+ require_relative 'riq_obj'
3
2
 
4
3
  module RIQ
4
+ # A List is an object that can be created and customized by a User to represent
5
+ # Accounts (companies) or Contacts (people) in a process (such as a sales pipeline).
5
6
  class List < RIQObject
6
7
  # can't create a list through api, so these don't need to write
7
8
  attr_reader :title
@@ -21,7 +22,7 @@ module RIQ
21
22
  self.class.node(@id)
22
23
  end
23
24
 
24
- # (see RIQObject#node)
25
+ # (see RIQObject.node)
25
26
  def self.node(id = nil)
26
27
  "lists/#{id}"
27
28
  end
@@ -36,7 +37,7 @@ module RIQ
36
37
  }
37
38
  end
38
39
 
39
- # Overwriting parent because litsts can't be saved through the API
40
+ # Overwriting parent because lists can't be saved through the API
40
41
  def save
41
42
  raise NotImplementedError, "Lists can't be edited through the API"
42
43
  end
@@ -52,6 +53,8 @@ module RIQ
52
53
  end
53
54
  end
54
55
 
56
+ # Convenience method for fetching or creating a listitem from the given list
57
+ # @param oid [String, nil] ObjectId
55
58
  def list_item(oid = nil)
56
59
  RIQ::ListItem.new(oid, lid: @id)
57
60
  end
@@ -75,13 +78,12 @@ module RIQ
75
78
  end
76
79
 
77
80
  class << self
78
- # Convenince method to create new Lists
81
+ # Convenience method to create new Lists
79
82
  # @param id [String, nil] create a blank List object or
80
83
  # fetch an existing one by id.
81
84
  # @return [List]
82
85
  def list(id = nil)
83
86
  List.new(id)
84
87
  end
85
- # TODO: could also just have #lists that returns whatever i'm supposed to be returning for my generator
86
88
  end
87
89
  end
@@ -1,13 +1,12 @@
1
-
1
+ require_relative 'batch_manager'
2
2
 
3
3
  module RIQ
4
+ # Special child for initializing list items, who need to include extra info.
4
5
  class ListItemManager < BatchManager
5
-
6
6
  def initialize(lid, page_length = 200)
7
7
  raise RIQError, 'List id can\'t be nil' if lid.nil?
8
8
  @list_id = lid
9
9
  super(RIQ::ListItem, page_length)
10
10
  end
11
-
12
11
  end
13
12
  end
@@ -1,6 +1,7 @@
1
-
1
+ require_relative 'riq_obj'
2
2
 
3
3
  module RIQ
4
+ # A List Item is a row in a List.
4
5
  class ListItem < RIQObject
5
6
  attr_accessor :name
6
7
  attr_accessor :field_values
@@ -31,7 +32,9 @@ module RIQ
31
32
  self.class.node(@list_id, @id)
32
33
  end
33
34
 
34
- # (see #node)
35
+ # @note this is the only object for which you have to include two params
36
+ # @param lid [String] ListId that the lit item belongs to
37
+ # @param oid [String] ObjectId for the object
35
38
  def self.node(lid = nil, oid = nil)
36
39
  # weird workaround for fetching node on init
37
40
  if lid.nil? && !oid.nil?
@@ -1,17 +1,14 @@
1
- # the objcet from which accounts, lists, items, etc will inherit
2
-
3
- require 'pp'
4
- require 'json'
5
1
  require_relative 'client'
6
2
 
7
-
8
3
  module RIQ
9
4
  # @abstract This class should not be used directly.
10
- # Instead, use a child such as {Contact} or {Account}.
5
+ # Instead, use a child such as {Contact} or {List}.
11
6
  class RIQObject
12
7
  attr_accessor :id
13
8
  # attr_reader :modified_date
14
9
 
10
+ # @param id [String, Hash] ObjectId or well-formatted hash of data (usually provided by another object
11
+ # @return [RIQObject] Self
15
12
  def initialize(id = nil)
16
13
  @client = RIQ.client
17
14
  @id = id
@@ -22,7 +19,7 @@ module RIQ
22
19
  # this looks dumb, could name variables better
23
20
  data = @id
24
21
  else
25
- data = @client.fetch(node)
22
+ data = @client.get(node)
26
23
  end
27
24
  init(data)
28
25
  else
@@ -36,6 +33,12 @@ module RIQ
36
33
  raise RIQError, 'This should be overwritten'
37
34
  end
38
35
 
36
+ # @param id [String] Objectid
37
+ # @return [String] endpoint
38
+ def self.node(id = nil)
39
+ raise RIQError, 'This should be overwritten'
40
+ end
41
+
39
42
  # @return [Hash] all relevant stored data
40
43
  def data
41
44
  raise RIQError, 'This should be overwritten'
@@ -43,7 +46,15 @@ module RIQ
43
46
 
44
47
  # @return [String] the json representation of {#data}
45
48
  def payload
46
- data.to_json
49
+ pld = {}
50
+ data.each do |k, v|
51
+ if k['_']
52
+ pld[camel_case(k)] = v
53
+ else
54
+ pld[k] = v
55
+ end
56
+ end
57
+ pld.to_json
47
58
  end
48
59
 
49
60
  # Creates or updates the object
@@ -57,6 +68,8 @@ module RIQ
57
68
  end
58
69
  end
59
70
 
71
+ # Deletes the object
72
+ # @note This is IRREVERSIBLE
60
73
  def delete
61
74
  @client.delete(node)
62
75
  end
@@ -1,6 +1,7 @@
1
- # users are things
1
+ require_relative 'riq_obj'
2
2
 
3
3
  module RIQ
4
+ # Users are represented by owners and contacts in your RelateIQ organization
4
5
  class User < RIQObject
5
6
  attr_accessor :name
6
7
  attr_accessor :email
@@ -33,4 +34,14 @@ module RIQ
33
34
  self
34
35
  end
35
36
  end
37
+
38
+ class << self
39
+ # Convenience method to create new Users
40
+ # @param id [String, nil] create a blank User object or
41
+ # fetch an existing one by id.
42
+ # @return [User]
43
+ def user(id = nil)
44
+ RIQ::User.new(id)
45
+ end
46
+ end
36
47
  end
@@ -1,11 +1,10 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'riq/version'
2
+ # lib = File.expand_path('../lib', __FILE__)
3
+ # $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = 'riq'
8
- spec.version = RIQ::VERSION
7
+ spec.version = '0.8.8'
9
8
  spec.authors = ['David Brownman']
10
9
  spec.email = ['david@relateiq.com']
11
10
  spec.homepage = "https://github.com/relateiq/ruby-sdk"
@@ -21,7 +20,7 @@ Gem::Specification.new do |spec|
21
20
  # spec.post_install_message = 'The power of relationship intelligence is in your hands!'
22
21
 
23
22
  # prod dependencies
24
- spec.add_dependency 'httparty', '~> 0.13'
23
+ spec.add_dependency 'httparty', '0.13.3'
25
24
 
26
25
  # dev dependencies
27
26
  spec.add_development_dependency 'bundler', '~> 1.7'
@@ -1,5 +1,5 @@
1
1
  require 'minitest/autorun'
2
- require_relative '../lib/relateiq'
2
+ require_relative '../lib/riq'
3
3
 
4
4
  describe RIQ::Account do
5
5
  before do
@@ -1,5 +1,5 @@
1
1
  require 'minitest/autorun'
2
- require_relative '../lib/relateiq'
2
+ require_relative '../lib/riq'
3
3
 
4
4
  describe RIQ::BatchManager do
5
5
  before do
@@ -1,5 +1,5 @@
1
1
  require 'minitest/autorun'
2
- require_relative '../lib/relateiq'
2
+ require_relative '../lib/riq'
3
3
 
4
4
  describe RIQ::Contact do
5
5
  before do
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Brownman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-14 00:00:00.000000000 Z
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0.13'
19
+ version: 0.13.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '0.13'
26
+ version: 0.13.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -48,19 +48,20 @@ files:
48
48
  - ".gitignore"
49
49
  - ".yardopts"
50
50
  - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
51
53
  - lib/riq.rb
52
54
  - lib/riq/account.rb
53
55
  - lib/riq/batch_manager.rb
54
56
  - lib/riq/client.rb
55
57
  - lib/riq/contact.rb
56
58
  - lib/riq/error.rb
57
- - lib/riq/events.rb
59
+ - lib/riq/event.rb
58
60
  - lib/riq/list.rb
59
61
  - lib/riq/list_item_manager.rb
60
62
  - lib/riq/listitem.rb
61
63
  - lib/riq/riq_obj.rb
62
64
  - lib/riq/user.rb
63
- - lib/riq/version.rb
64
65
  - riq.gemspec
65
66
  - test/test.rb
66
67
  - test/test_account.rb
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  version: '0'
87
88
  requirements: []
88
89
  rubyforge_project:
89
- rubygems_version: 2.2.2
90
+ rubygems_version: 2.4.6
90
91
  signing_key:
91
92
  specification_version: 4
92
93
  summary: Ruby RIQ API client
@@ -1,3 +0,0 @@
1
- module RIQ
2
- VERSION = "0.8.5"
3
- end