basecrm 1.3.2 → 1.3.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.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE +1 -1
  3. data/README.md +24 -0
  4. data/lib/basecrm.rb +22 -0
  5. data/lib/basecrm/models/deal.rb +3 -3
  6. data/lib/basecrm/models/deal_unqualified_reason.rb +22 -0
  7. data/lib/basecrm/models/lead_unqualified_reason.rb +22 -0
  8. data/lib/basecrm/services/accounts_service.rb +3 -3
  9. data/lib/basecrm/services/associated_contacts_service.rb +12 -12
  10. data/lib/basecrm/services/contacts_service.rb +19 -19
  11. data/lib/basecrm/services/deal_unqualified_reasons_service.rb +133 -0
  12. data/lib/basecrm/services/lead_sources_service.rb +19 -19
  13. data/lib/basecrm/services/lead_unqualified_reasons_service.rb +45 -0
  14. data/lib/basecrm/services/leads_service.rb +19 -19
  15. data/lib/basecrm/services/loss_reasons_service.rb +19 -19
  16. data/lib/basecrm/services/notes_service.rb +19 -19
  17. data/lib/basecrm/services/pipelines_service.rb +5 -5
  18. data/lib/basecrm/services/sources_service.rb +19 -19
  19. data/lib/basecrm/services/stages_service.rb +5 -5
  20. data/lib/basecrm/services/tags_service.rb +19 -19
  21. data/lib/basecrm/services/tasks_service.rb +19 -19
  22. data/lib/basecrm/services/users_service.rb +11 -11
  23. data/lib/basecrm/version.rb +1 -1
  24. data/spec/factories/deal_unqualified_reason.rb +11 -0
  25. data/spec/factories/lead_unqualified_reason.rb +0 -0
  26. data/spec/services/accounts_service_spec.rb +1 -2
  27. data/spec/services/associated_contacts_service_spec.rb +0 -1
  28. data/spec/services/contacts_service_spec.rb +1 -2
  29. data/spec/services/deal_sources_service_spec.rb +1 -2
  30. data/spec/services/deal_unqualified_reasons_service_spec.rb +57 -0
  31. data/spec/services/lead_sources_service_spec.rb +1 -2
  32. data/spec/services/lead_unqualified_reasons_service_spec.rb +22 -0
  33. data/spec/services/leads_service_spec.rb +1 -2
  34. data/spec/services/line_items_service_spec.rb +0 -1
  35. data/spec/services/loss_reasons_service_spec.rb +1 -2
  36. data/spec/services/notes_service_spec.rb +1 -2
  37. data/spec/services/orders_service_spec.rb +0 -1
  38. data/spec/services/pipelines_service_spec.rb +0 -1
  39. data/spec/services/products_service_spec.rb +1 -2
  40. data/spec/services/sources_service_spec.rb +1 -2
  41. data/spec/services/stages_service_spec.rb +0 -1
  42. data/spec/services/tags_service_spec.rb +1 -2
  43. data/spec/services/tasks_service_spec.rb +1 -2
  44. data/spec/services/users_service_spec.rb +1 -3
  45. metadata +15 -3
@@ -7,17 +7,17 @@ module BaseCRM
7
7
  end
8
8
 
9
9
  # Retrieve all pipelines
10
- #
10
+ #
11
11
  # get '/pipelines'
12
12
  #
13
13
  # If you want to use filtering or sorting (see #where).
14
- # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
14
+ # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
15
15
  def all
16
16
  PaginatedResource.new(self)
17
17
  end
18
18
 
19
19
  # Retrieve all pipelines
20
- #
20
+ #
21
21
  # get '/pipelines'
22
22
  #
23
23
  # Returns all pipelines available to the user, according to the parameters provided
@@ -28,13 +28,13 @@ module BaseCRM
28
28
  # @option options [Integer] :page (1) The page number to start from. Page numbering starts at 1, and omitting the `page` parameter will return the first page.
29
29
  # @option options [Integer] :per_page (25) The number of records to be returned per page. The default limit is *25* and the maximum number that can be returned is *100*.
30
30
  # @option options [String] :sort_by (id:asc) Comma-separated list of fields to sort by. The sort criteria is applied in the order specified. The **default** ordering is **ascending**. If you want to change the sort ordering to descending, append `:desc` to the field e.g. `sort_by=position:desc`. Unsupported for now.
31
- # @return [Array<Pipeline>] The list of Pipelines for the first page, unless otherwise specified.
31
+ # @return [Array<Pipeline>] The list of Pipelines for the first page, unless otherwise specified.
32
32
  def where(options = {})
33
33
  _, _, root = @client.get("/pipelines", options)
34
34
 
35
35
  root[:items].map{ |item| Pipeline.new(item[:data]) }
36
36
  end
37
-
37
+
38
38
 
39
39
  private
40
40
  def validate_type!(pipeline)
@@ -9,17 +9,17 @@ module BaseCRM
9
9
  end
10
10
 
11
11
  # Retrieve all sources
12
- #
12
+ #
13
13
  # get '/sources'
14
14
  #
15
15
  # If you want to use filtering or sorting (see #where).
16
- # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
16
+ # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
17
17
  def all
18
18
  PaginatedResource.new(self)
19
19
  end
20
20
 
21
21
  # Retrieve all sources
22
- #
22
+ #
23
23
  # get '/sources'
24
24
  #
25
25
  # Returns all deal sources available to the user according to the parameters provided
@@ -30,16 +30,16 @@ module BaseCRM
30
30
  # @option options [Integer] :page (1) Page number to start from. Page numbering starts at 1, and omitting the `page` parameter will return the first page.
31
31
  # @option options [Integer] :per_page (25) Number of records to return per page. The default limit is *25* and the maximum number that can be returned is *100*.
32
32
  # @option options [String] :sort_by (id:asc) A field to sort by. The **default** ordering is **ascending**. If you want to change the sort order to descending, append `:desc` to the field e.g. `sort_by=name:desc`.
33
- # @return [Array<Source>] The list of Sources for the first page, unless otherwise specified.
33
+ # @return [Array<Source>] The list of Sources for the first page, unless otherwise specified.
34
34
  def where(options = {})
35
35
  _, _, root = @client.get("/sources", options)
36
36
 
37
37
  root[:items].map{ |item| Source.new(item[:data]) }
38
38
  end
39
-
39
+
40
40
 
41
41
  # Create a source
42
- #
42
+ #
43
43
  # post '/sources'
44
44
  #
45
45
  # Creates a new source
@@ -47,8 +47,8 @@ module BaseCRM
47
47
  # Source's name **must** be unique
48
48
  # </figure>
49
49
  #
50
- # @param source [Source, Hash] Either object of the Source type or Hash. This object's attributes describe the object to be created.
51
- # @return [Source] The resulting object represting created resource.
50
+ # @param source [Source, Hash] Either object of the Source type or Hash. This object's attributes describe the object to be created.
51
+ # @return [Source] The resulting object represting created resource.
52
52
  def create(source)
53
53
  validate_type!(source)
54
54
 
@@ -57,26 +57,26 @@ module BaseCRM
57
57
 
58
58
  Source.new(root[:data])
59
59
  end
60
-
60
+
61
61
 
62
62
  # Retrieve a single source
63
- #
63
+ #
64
64
  # get '/sources/{id}'
65
65
  #
66
66
  # Returns a single source available to the user by the provided id
67
67
  # If a source with the supplied unique identifier does not exist it returns an error
68
68
  #
69
69
  # @param id [Integer] Unique identifier of a Source
70
- # @return [Source] Searched resource object.
70
+ # @return [Source] Searched resource object.
71
71
  def find(id)
72
72
  _, _, root = @client.get("/sources/#{id}")
73
73
 
74
74
  Source.new(root[:data])
75
75
  end
76
-
76
+
77
77
 
78
78
  # Update a source
79
- #
79
+ #
80
80
  # put '/sources/{id}'
81
81
  #
82
82
  # Updates source information
@@ -85,8 +85,8 @@ module BaseCRM
85
85
  # If you want to update a source, you **must** make sure source's name is unique
86
86
  # </figure>
87
87
  #
88
- # @param source [Source, Hash] Either object of the Source type or Hash. This object's attributes describe the object to be updated.
89
- # @return [Source] The resulting object represting updated resource.
88
+ # @param source [Source, Hash] Either object of the Source type or Hash. This object's attributes describe the object to be updated.
89
+ # @return [Source] The resulting object represting updated resource.
90
90
  def update(source)
91
91
  validate_type!(source)
92
92
  params = extract_params!(source, :id)
@@ -97,10 +97,10 @@ module BaseCRM
97
97
 
98
98
  Source.new(root[:data])
99
99
  end
100
-
100
+
101
101
 
102
102
  # Delete a source
103
- #
103
+ #
104
104
  # delete '/sources/{id}'
105
105
  #
106
106
  # Delete an existing source
@@ -113,7 +113,7 @@ module BaseCRM
113
113
  status, _, _ = @client.delete("/sources/#{id}")
114
114
  status == 204
115
115
  end
116
-
116
+
117
117
 
118
118
  private
119
119
  def validate_type!(source)
@@ -125,7 +125,7 @@ module BaseCRM
125
125
  raise ArgumentError, "one of required attributes is missing. Expected: #{args.join(',')}" if params.count != args.length
126
126
  params
127
127
  end
128
-
128
+
129
129
  def sanitize(source)
130
130
  source.to_h.select { |k, _| OPTS_KEYS_TO_PERSIST.include?(k) }
131
131
  end
@@ -7,17 +7,17 @@ module BaseCRM
7
7
  end
8
8
 
9
9
  # Retrieve all stages
10
- #
10
+ #
11
11
  # get '/stages'
12
12
  #
13
13
  # If you want to use filtering or sorting (see #where).
14
- # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
14
+ # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
15
15
  def all
16
16
  PaginatedResource.new(self)
17
17
  end
18
18
 
19
19
  # Retrieve all stages
20
- #
20
+ #
21
21
  # get '/stages'
22
22
  #
23
23
  # Returns all stages available to the user, according to the parameters provided
@@ -30,13 +30,13 @@ module BaseCRM
30
30
  # @option options [Integer] :per_page (25) The number of records to return per page. The default limit is *25* and the maximum number that can be returned is *100*.
31
31
  # @option options [Integer] :pipeline_id (1) The unique identifier of the pipeline that contains this stage.
32
32
  # @option options [String] :sort_by (id:asc) Comma-separated list of fields to sort by. The sort criteria is applied in the order specified. The **default** ordering is **ascending**. If you want to change the sort ordering to descending, append `:desc` to the field e.g. `sort_by=position:desc`. Unsupported for now.
33
- # @return [Array<Stage>] The list of Stages for the first page, unless otherwise specified.
33
+ # @return [Array<Stage>] The list of Stages for the first page, unless otherwise specified.
34
34
  def where(options = {})
35
35
  _, _, root = @client.get("/stages", options)
36
36
 
37
37
  root[:items].map{ |item| Stage.new(item[:data]) }
38
38
  end
39
-
39
+
40
40
 
41
41
  private
42
42
  def validate_type!(stage)
@@ -9,17 +9,17 @@ module BaseCRM
9
9
  end
10
10
 
11
11
  # Retrieve all tags
12
- #
12
+ #
13
13
  # get '/tags'
14
14
  #
15
15
  # If you want to use filtering or sorting (see #where).
16
- # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
16
+ # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
17
17
  def all
18
18
  PaginatedResource.new(self)
19
19
  end
20
20
 
21
21
  # Retrieve all tags
22
- #
22
+ #
23
23
  # get '/tags'
24
24
  #
25
25
  # Returns all tags available to the user, according to the parameters provided
@@ -32,23 +32,23 @@ module BaseCRM
32
32
  # @option options [Integer] :per_page (25) Number of records to return per page. The default limit is *25* and the maximum number that can be returned is *100*.
33
33
  # @option options [String] :resource_type Type name of resource to search for.
34
34
  # @option options [String] :sort_by (updated_at:asc) A field to sort by. The **default** order is **ascending**. If you want to change the sort order to descending, append `:desc` to the field e.g. `sort_by=name:desc`.
35
- # @return [Array<Tag>] The list of Tags for the first page, unless otherwise specified.
35
+ # @return [Array<Tag>] The list of Tags for the first page, unless otherwise specified.
36
36
  def where(options = {})
37
37
  _, _, root = @client.get("/tags", options)
38
38
 
39
39
  root[:items].map{ |item| Tag.new(item[:data]) }
40
40
  end
41
-
41
+
42
42
 
43
43
  # Create a tag
44
- #
44
+ #
45
45
  # post '/tags'
46
46
  #
47
47
  # Creates a new tag
48
48
  # **Notice** the tag's name **must** be unique within the scope of the resource_type
49
49
  #
50
- # @param tag [Tag, Hash] Either object of the Tag type or Hash. This object's attributes describe the object to be created.
51
- # @return [Tag] The resulting object represting created resource.
50
+ # @param tag [Tag, Hash] Either object of the Tag type or Hash. This object's attributes describe the object to be created.
51
+ # @return [Tag] The resulting object represting created resource.
52
52
  def create(tag)
53
53
  validate_type!(tag)
54
54
 
@@ -57,34 +57,34 @@ module BaseCRM
57
57
 
58
58
  Tag.new(root[:data])
59
59
  end
60
-
60
+
61
61
 
62
62
  # Retrieve a single tag
63
- #
63
+ #
64
64
  # get '/tags/{id}'
65
65
  #
66
66
  # Returns a single tag available to the user according to the unique ID provided
67
67
  # If the specified tag does not exist, this query will return an error
68
68
  #
69
69
  # @param id [Integer] Unique identifier of a Tag
70
- # @return [Tag] Searched resource object.
70
+ # @return [Tag] Searched resource object.
71
71
  def find(id)
72
72
  _, _, root = @client.get("/tags/#{id}")
73
73
 
74
74
  Tag.new(root[:data])
75
75
  end
76
-
76
+
77
77
 
78
78
  # Update a tag
79
- #
79
+ #
80
80
  # put '/tags/{id}'
81
81
  #
82
82
  # Updates a tag's information
83
83
  # If the specified tag does not exist, this query will return an error
84
84
  # **Notice** if you want to update a tag, you **must** make sure the tag's name is unique within the scope of the specified resource
85
85
  #
86
- # @param tag [Tag, Hash] Either object of the Tag type or Hash. This object's attributes describe the object to be updated.
87
- # @return [Tag] The resulting object represting updated resource.
86
+ # @param tag [Tag, Hash] Either object of the Tag type or Hash. This object's attributes describe the object to be updated.
87
+ # @return [Tag] The resulting object represting updated resource.
88
88
  def update(tag)
89
89
  validate_type!(tag)
90
90
  params = extract_params!(tag, :id)
@@ -95,10 +95,10 @@ module BaseCRM
95
95
 
96
96
  Tag.new(root[:data])
97
97
  end
98
-
98
+
99
99
 
100
100
  # Delete a tag
101
- #
101
+ #
102
102
  # delete '/tags/{id}'
103
103
  #
104
104
  # Deletes an existing tag
@@ -112,7 +112,7 @@ module BaseCRM
112
112
  status, _, _ = @client.delete("/tags/#{id}")
113
113
  status == 204
114
114
  end
115
-
115
+
116
116
 
117
117
  private
118
118
  def validate_type!(tag)
@@ -124,7 +124,7 @@ module BaseCRM
124
124
  raise ArgumentError, "one of required attributes is missing. Expected: #{args.join(',')}" if params.count != args.length
125
125
  params
126
126
  end
127
-
127
+
128
128
  def sanitize(tag)
129
129
  tag.to_h.select { |k, _| OPTS_KEYS_TO_PERSIST.include?(k) }
130
130
  end
@@ -9,17 +9,17 @@ module BaseCRM
9
9
  end
10
10
 
11
11
  # Retrieve all tasks
12
- #
12
+ #
13
13
  # get '/tasks'
14
14
  #
15
15
  # If you want to use filtering or sorting (see #where).
16
- # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
16
+ # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
17
17
  def all
18
18
  PaginatedResource.new(self)
19
19
  end
20
20
 
21
21
  # Retrieve all tasks
22
- #
22
+ #
23
23
  # get '/tasks'
24
24
  #
25
25
  # Returns all tasks available to the user, according to the parameters provided
@@ -40,16 +40,16 @@ module BaseCRM
40
40
  # @option options [String] :resource_type Name of the resource type to search for.
41
41
  # @option options [String] :sort_by (updated_at:asc) A field to sort by. The **default** ordering is **ascending**. If you want to change the sort order to descending, append `:desc` to the field e.g. `sort_by=resource_type:desc`.
42
42
  # @option options [String] :type Type of tasks to search for.
43
- # @return [Array<Task>] The list of Tasks for the first page, unless otherwise specified.
43
+ # @return [Array<Task>] The list of Tasks for the first page, unless otherwise specified.
44
44
  def where(options = {})
45
45
  _, _, root = @client.get("/tasks", options)
46
46
 
47
47
  root[:items].map{ |item| Task.new(item[:data]) }
48
48
  end
49
-
49
+
50
50
 
51
51
  # Create a task
52
- #
52
+ #
53
53
  # post '/tasks'
54
54
  #
55
55
  # Creates a new task
@@ -58,8 +58,8 @@ module BaseCRM
58
58
  # * [Contacts](/docs/rest/reference/contacts)
59
59
  # * [Deals](/docs/rest/reference/deals)
60
60
  #
61
- # @param task [Task, Hash] Either object of the Task type or Hash. This object's attributes describe the object to be created.
62
- # @return [Task] The resulting object represting created resource.
61
+ # @param task [Task, Hash] Either object of the Task type or Hash. This object's attributes describe the object to be created.
62
+ # @return [Task] The resulting object represting created resource.
63
63
  def create(task)
64
64
  validate_type!(task)
65
65
 
@@ -68,33 +68,33 @@ module BaseCRM
68
68
 
69
69
  Task.new(root[:data])
70
70
  end
71
-
71
+
72
72
 
73
73
  # Retrieve a single task
74
- #
74
+ #
75
75
  # get '/tasks/{id}'
76
76
  #
77
77
  # Returns a single task available to the user according to the unique task ID provided
78
78
  # If the specified task does not exist, this query will return an error
79
79
  #
80
80
  # @param id [Integer] Unique identifier of a Task
81
- # @return [Task] Searched resource object.
81
+ # @return [Task] Searched resource object.
82
82
  def find(id)
83
83
  _, _, root = @client.get("/tasks/#{id}")
84
84
 
85
85
  Task.new(root[:data])
86
86
  end
87
-
87
+
88
88
 
89
89
  # Update a task
90
- #
90
+ #
91
91
  # put '/tasks/{id}'
92
92
  #
93
93
  # Updates task information
94
94
  # If the specified task does not exist, this query will return an error
95
95
  #
96
- # @param task [Task, Hash] Either object of the Task type or Hash. This object's attributes describe the object to be updated.
97
- # @return [Task] The resulting object represting updated resource.
96
+ # @param task [Task, Hash] Either object of the Task type or Hash. This object's attributes describe the object to be updated.
97
+ # @return [Task] The resulting object represting updated resource.
98
98
  def update(task)
99
99
  validate_type!(task)
100
100
  params = extract_params!(task, :id)
@@ -105,10 +105,10 @@ module BaseCRM
105
105
 
106
106
  Task.new(root[:data])
107
107
  end
108
-
108
+
109
109
 
110
110
  # Delete a task
111
- #
111
+ #
112
112
  # delete '/tasks/{id}'
113
113
  #
114
114
  # Delete an existing task
@@ -121,7 +121,7 @@ module BaseCRM
121
121
  status, _, _ = @client.delete("/tasks/#{id}")
122
122
  status == 204
123
123
  end
124
-
124
+
125
125
 
126
126
  private
127
127
  def validate_type!(task)
@@ -133,7 +133,7 @@ module BaseCRM
133
133
  raise ArgumentError, "one of required attributes is missing. Expected: #{args.join(',')}" if params.count != args.length
134
134
  params
135
135
  end
136
-
136
+
137
137
  def sanitize(task)
138
138
  task.to_h.select { |k, _| OPTS_KEYS_TO_PERSIST.include?(k) }
139
139
  end
@@ -7,17 +7,17 @@ module BaseCRM
7
7
  end
8
8
 
9
9
  # Retrieve all users
10
- #
10
+ #
11
11
  # get '/users'
12
12
  #
13
13
  # If you want to use filtering or sorting (see #where).
14
- # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
14
+ # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
15
15
  def all
16
16
  PaginatedResource.new(self)
17
17
  end
18
18
 
19
19
  # Retrieve all users
20
- #
20
+ #
21
21
  # get '/users'
22
22
  #
23
23
  # Returns all users, according to the parameters provided
@@ -32,37 +32,37 @@ module BaseCRM
32
32
  # @option options [String] :role Role of user to search for.
33
33
  # @option options [String] :sort_by (id:asc) A field to sort by. The **default** order is **ascending**. If you want to change the sort order to descending, append `:desc` to the field e.g. `sort_by=name:desc`.
34
34
  # @option options [String] :status Status of user accounts to search for.
35
- # @return [Array<User>] The list of Users for the first page, unless otherwise specified.
35
+ # @return [Array<User>] The list of Users for the first page, unless otherwise specified.
36
36
  def where(options = {})
37
37
  _, _, root = @client.get("/users", options)
38
38
 
39
39
  root[:items].map{ |item| User.new(item[:data]) }
40
40
  end
41
-
41
+
42
42
 
43
43
  # Retrieve a single user
44
- #
44
+ #
45
45
  # get '/users/{id}'
46
46
  #
47
47
  # Returns a single user according to the unique user ID provided
48
48
  # If the specified user does not exist, this query returns an error
49
49
  #
50
50
  # @param id [Integer] Unique identifier of a User
51
- # @return [User] Searched resource object.
51
+ # @return [User] Searched resource object.
52
52
  def find(id)
53
53
  _, _, root = @client.get("/users/#{id}")
54
54
 
55
55
  User.new(root[:data])
56
56
  end
57
-
58
-
57
+
58
+
59
59
  # Retrieve an authenticating user
60
- #
60
+ #
61
61
  # get '/users/self'
62
62
  #
63
63
  # Returns a single authenticating user, according to the authentication credentials provided
64
64
  #
65
- # @return [User] Resource object.
65
+ # @return [User] Resource object.
66
66
  def self
67
67
  _, _, root = @client.get("/users/self")
68
68
  User.new(root[:data])