basecrm 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -9,17 +9,17 @@ module BaseCRM
9
9
  end
10
10
 
11
11
  # Retrieve all sources
12
- #
12
+ #
13
13
  # get '/lead_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 '/lead_sources'
24
24
  #
25
25
  # Returns all lead 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<LeadSource>] The list of LeadSources for the first page, unless otherwise specified.
33
+ # @return [Array<LeadSource>] The list of LeadSources for the first page, unless otherwise specified.
34
34
  def where(options = {})
35
35
  _, _, root = @client.get("/lead_sources", options)
36
36
 
37
37
  root[:items].map{ |item| LeadSource.new(item[:data]) }
38
38
  end
39
-
39
+
40
40
 
41
41
  # Create a new source
42
- #
42
+ #
43
43
  # post '/lead_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 lead_source [LeadSource, Hash] Either object of the LeadSource type or Hash. This object's attributes describe the object to be created.
51
- # @return [LeadSource] The resulting object represting created resource.
50
+ # @param lead_source [LeadSource, Hash] Either object of the LeadSource type or Hash. This object's attributes describe the object to be created.
51
+ # @return [LeadSource] The resulting object represting created resource.
52
52
  def create(lead_source)
53
53
  validate_type!(lead_source)
54
54
 
@@ -57,26 +57,26 @@ module BaseCRM
57
57
 
58
58
  LeadSource.new(root[:data])
59
59
  end
60
-
60
+
61
61
 
62
62
  # Retrieve a single source
63
- #
63
+ #
64
64
  # get '/lead_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 LeadSource
70
- # @return [LeadSource] Searched resource object.
70
+ # @return [LeadSource] Searched resource object.
71
71
  def find(id)
72
72
  _, _, root = @client.get("/lead_sources/#{id}")
73
73
 
74
74
  LeadSource.new(root[:data])
75
75
  end
76
-
76
+
77
77
 
78
78
  # Update a source
79
- #
79
+ #
80
80
  # put '/lead_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 lead_source [LeadSource, Hash] Either object of the LeadSource type or Hash. This object's attributes describe the object to be updated.
89
- # @return [LeadSource] The resulting object represting updated resource.
88
+ # @param lead_source [LeadSource, Hash] Either object of the LeadSource type or Hash. This object's attributes describe the object to be updated.
89
+ # @return [LeadSource] The resulting object represting updated resource.
90
90
  def update(lead_source)
91
91
  validate_type!(lead_source)
92
92
  params = extract_params!(lead_source, :id)
@@ -97,10 +97,10 @@ module BaseCRM
97
97
 
98
98
  LeadSource.new(root[:data])
99
99
  end
100
-
100
+
101
101
 
102
102
  # Delete a source
103
- #
103
+ #
104
104
  # delete '/lead_sources/{id}'
105
105
  #
106
106
  # Delete an existing source
@@ -113,7 +113,7 @@ module BaseCRM
113
113
  status, _, _ = @client.delete("/lead_sources/#{id}")
114
114
  status == 204
115
115
  end
116
-
116
+
117
117
 
118
118
  private
119
119
  def validate_type!(lead_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(lead_source)
130
130
  lead_source.to_h.select { |k, _| OPTS_KEYS_TO_PERSIST.include?(k) }
131
131
  end
@@ -0,0 +1,45 @@
1
+ # WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
2
+
3
+ module BaseCRM
4
+ class LeadUnqualifiedReasonsService
5
+ def initialize(client)
6
+ @client = client
7
+ end
8
+
9
+ # Retrieve all lead unqualified reasons
10
+ #
11
+ # get '/lead_unqualified_reasons'
12
+ #
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.
15
+ def all
16
+ PaginatedResource.new(self)
17
+ end
18
+
19
+ # Retrieve all lead unqualified reasons
20
+ #
21
+ # get '/lead_unqualified_reasons'
22
+ #
23
+ # Returns all lead unqualified reasons available to the user according to the parameters provided
24
+ #
25
+ # @param options [Hash] Search options
26
+ # @return [Array<LeadUnqualifiedReason>] The list of LeadUnqualifiedReasons for the first page, unless otherwise specified.
27
+ def where(options = {})
28
+ _, _, root = @client.get("/lead_unqualified_reasons", options)
29
+
30
+ root[:items].map{ |item| LeadUnqualifiedReason.new(item[:data]) }
31
+ end
32
+
33
+
34
+ private
35
+ def validate_type!(lead_unqualified_reason)
36
+ raise TypeError unless lead_unqualified_reason.is_a?(LeadUnqualifiedReason) || lead_unqualified_reason.is_a?(Hash)
37
+ end
38
+
39
+ def extract_params!(lead_unqualified_reason, *args)
40
+ params = lead_unqualified_reason.to_h.select{ |k, _| args.include?(k) }
41
+ raise ArgumentError, "one of required attributes is missing. Expected: #{args.join(',')}" if params.count != args.length
42
+ params
43
+ end
44
+ end
45
+ end
@@ -9,17 +9,17 @@ module BaseCRM
9
9
  end
10
10
 
11
11
  # Retrieve all leads
12
- #
12
+ #
13
13
  # get '/leads'
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 leads
22
- #
22
+ #
23
23
  # get '/leads'
24
24
  #
25
25
  # Returns all leads available to the user, according to the parameters provided
@@ -39,23 +39,23 @@ module BaseCRM
39
39
  # @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*.
40
40
  # @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=last_name:desc`.
41
41
  # @option options [String] :status Status of the lead.
42
- # @return [Array<Lead>] The list of Leads for the first page, unless otherwise specified.
42
+ # @return [Array<Lead>] The list of Leads for the first page, unless otherwise specified.
43
43
  def where(options = {})
44
44
  _, _, root = @client.get("/leads", options)
45
45
 
46
46
  root[:items].map{ |item| Lead.new(item[:data]) }
47
47
  end
48
-
48
+
49
49
 
50
50
  # Create a lead
51
- #
51
+ #
52
52
  # post '/leads'
53
53
  #
54
54
  # Creates a new lead
55
55
  # A lead may represent a single individual or an organization
56
56
  #
57
- # @param lead [Lead, Hash] Either object of the Lead type or Hash. This object's attributes describe the object to be created.
58
- # @return [Lead] The resulting object represting created resource.
57
+ # @param lead [Lead, Hash] Either object of the Lead type or Hash. This object's attributes describe the object to be created.
58
+ # @return [Lead] The resulting object represting created resource.
59
59
  def create(lead)
60
60
  validate_type!(lead)
61
61
 
@@ -64,26 +64,26 @@ module BaseCRM
64
64
 
65
65
  Lead.new(root[:data])
66
66
  end
67
-
67
+
68
68
 
69
69
  # Retrieve a single lead
70
- #
70
+ #
71
71
  # get '/leads/{id}'
72
72
  #
73
73
  # Returns a single lead available to the user, according to the unique lead ID provided
74
74
  # If the specified lead does not exist, this query returns an error
75
75
  #
76
76
  # @param id [Integer] Unique identifier of a Lead
77
- # @return [Lead] Searched resource object.
77
+ # @return [Lead] Searched resource object.
78
78
  def find(id)
79
79
  _, _, root = @client.get("/leads/#{id}")
80
80
 
81
81
  Lead.new(root[:data])
82
82
  end
83
-
83
+
84
84
 
85
85
  # Update a lead
86
- #
86
+ #
87
87
  # put '/leads/{id}'
88
88
  #
89
89
  # Updates lead information
@@ -93,8 +93,8 @@ module BaseCRM
93
93
  # `tags` are replaced every time they are used in a request
94
94
  # </figure>
95
95
  #
96
- # @param lead [Lead, Hash] Either object of the Lead type or Hash. This object's attributes describe the object to be updated.
97
- # @return [Lead] The resulting object represting updated resource.
96
+ # @param lead [Lead, Hash] Either object of the Lead type or Hash. This object's attributes describe the object to be updated.
97
+ # @return [Lead] The resulting object represting updated resource.
98
98
  def update(lead)
99
99
  validate_type!(lead)
100
100
  params = extract_params!(lead, :id)
@@ -105,10 +105,10 @@ module BaseCRM
105
105
 
106
106
  Lead.new(root[:data])
107
107
  end
108
-
108
+
109
109
 
110
110
  # Delete a lead
111
- #
111
+ #
112
112
  # delete '/leads/{id}'
113
113
  #
114
114
  # Delete an existing lead
@@ -121,7 +121,7 @@ module BaseCRM
121
121
  status, _, _ = @client.delete("/leads/#{id}")
122
122
  status == 204
123
123
  end
124
-
124
+
125
125
 
126
126
  private
127
127
  def validate_type!(lead)
@@ -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(lead)
138
138
  lead.to_h.select { |k, _| OPTS_KEYS_TO_PERSIST.include?(k) }
139
139
  end
@@ -9,17 +9,17 @@ module BaseCRM
9
9
  end
10
10
 
11
11
  # Retrieve all reasons
12
- #
12
+ #
13
13
  # get '/loss_reasons'
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 reasons
22
- #
22
+ #
23
23
  # get '/loss_reasons'
24
24
  #
25
25
  # Returns all deal loss reasons 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 is 1-based and omitting `page` parameter will return the first page.
31
31
  # @option options [Integer] :per_page (25) Number of records to return per page. Default limit is *25* and maximum number that can be returned is *100*.
32
32
  # @option options [String] :sort_by (id:asc) A field to sort by. **Default** ordering is **ascending**. If you want to change the sort ordering to descending, append `:desc` to the field e.g. `sort_by=name:desc`.
33
- # @return [Array<LossReason>] The list of LossReasons for the first page, unless otherwise specified.
33
+ # @return [Array<LossReason>] The list of LossReasons for the first page, unless otherwise specified.
34
34
  def where(options = {})
35
35
  _, _, root = @client.get("/loss_reasons", options)
36
36
 
37
37
  root[:items].map{ |item| LossReason.new(item[:data]) }
38
38
  end
39
-
39
+
40
40
 
41
41
  # Create a loss reason
42
- #
42
+ #
43
43
  # post '/loss_reasons'
44
44
  #
45
45
  # Create a new loss reason
@@ -47,8 +47,8 @@ module BaseCRM
47
47
  # Loss reason's name **must** be unique
48
48
  # </figure>
49
49
  #
50
- # @param loss_reason [LossReason, Hash] Either object of the LossReason type or Hash. This object's attributes describe the object to be created.
51
- # @return [LossReason] The resulting object represting created resource.
50
+ # @param loss_reason [LossReason, Hash] Either object of the LossReason type or Hash. This object's attributes describe the object to be created.
51
+ # @return [LossReason] The resulting object represting created resource.
52
52
  def create(loss_reason)
53
53
  validate_type!(loss_reason)
54
54
 
@@ -57,26 +57,26 @@ module BaseCRM
57
57
 
58
58
  LossReason.new(root[:data])
59
59
  end
60
-
60
+
61
61
 
62
62
  # Retrieve a single reason
63
- #
63
+ #
64
64
  # get '/loss_reasons/{id}'
65
65
  #
66
66
  # Returns a single loss reason available to the user by the provided id
67
67
  # If a loss reason with the supplied unique identifier does not exist, it returns an error
68
68
  #
69
69
  # @param id [Integer] Unique identifier of a LossReason
70
- # @return [LossReason] Searched resource object.
70
+ # @return [LossReason] Searched resource object.
71
71
  def find(id)
72
72
  _, _, root = @client.get("/loss_reasons/#{id}")
73
73
 
74
74
  LossReason.new(root[:data])
75
75
  end
76
-
76
+
77
77
 
78
78
  # Update a loss reason
79
- #
79
+ #
80
80
  # put '/loss_reasons/{id}'
81
81
  #
82
82
  # Updates a loss reason information
@@ -85,8 +85,8 @@ module BaseCRM
85
85
  # If you want to update loss reason you **must** make sure name of the reason is unique
86
86
  # </figure>
87
87
  #
88
- # @param loss_reason [LossReason, Hash] Either object of the LossReason type or Hash. This object's attributes describe the object to be updated.
89
- # @return [LossReason] The resulting object represting updated resource.
88
+ # @param loss_reason [LossReason, Hash] Either object of the LossReason type or Hash. This object's attributes describe the object to be updated.
89
+ # @return [LossReason] The resulting object represting updated resource.
90
90
  def update(loss_reason)
91
91
  validate_type!(loss_reason)
92
92
  params = extract_params!(loss_reason, :id)
@@ -97,10 +97,10 @@ module BaseCRM
97
97
 
98
98
  LossReason.new(root[:data])
99
99
  end
100
-
100
+
101
101
 
102
102
  # Delete a reason
103
- #
103
+ #
104
104
  # delete '/loss_reasons/{id}'
105
105
  #
106
106
  # Delete an existing loss reason
@@ -113,7 +113,7 @@ module BaseCRM
113
113
  status, _, _ = @client.delete("/loss_reasons/#{id}")
114
114
  status == 204
115
115
  end
116
-
116
+
117
117
 
118
118
  private
119
119
  def validate_type!(loss_reason)
@@ -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(loss_reason)
130
130
  loss_reason.to_h.select { |k, _| OPTS_KEYS_TO_PERSIST.include?(k) }
131
131
  end
@@ -9,17 +9,17 @@ module BaseCRM
9
9
  end
10
10
 
11
11
  # Retrieve all notes
12
- #
12
+ #
13
13
  # get '/notes'
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 notes
22
- #
22
+ #
23
23
  # get '/notes'
24
24
  #
25
25
  # Returns all notes available to the user, according to the parameters provided
@@ -34,16 +34,16 @@ module BaseCRM
34
34
  # @option options [Integer] :resource_id Unique identifier of the resource to search for.
35
35
  # @option options [String] :resource_type Name of the type of resource to search for.
36
36
  # @option options [String] :sort_by (updated_at:asc) A field to sort by. **Default** ordering is **ascending**. If you want to change the sort ordering to descending, append `:desc` to the field e.g. `sort_by=resource_type:desc`.
37
- # @return [Array<Note>] The list of Notes for the first page, unless otherwise specified.
37
+ # @return [Array<Note>] The list of Notes for the first page, unless otherwise specified.
38
38
  def where(options = {})
39
39
  _, _, root = @client.get("/notes", options)
40
40
 
41
41
  root[:items].map{ |item| Note.new(item[:data]) }
42
42
  end
43
-
43
+
44
44
 
45
45
  # Create a note
46
- #
46
+ #
47
47
  # post '/notes'
48
48
  #
49
49
  # Create a new note and associate it with one of the resources listed below:
@@ -51,8 +51,8 @@ module BaseCRM
51
51
  # * [Contacts](/docs/rest/reference/contacts)
52
52
  # * [Deals](/docs/rest/reference/deals)
53
53
  #
54
- # @param note [Note, Hash] Either object of the Note type or Hash. This object's attributes describe the object to be created.
55
- # @return [Note] The resulting object represting created resource.
54
+ # @param note [Note, Hash] Either object of the Note type or Hash. This object's attributes describe the object to be created.
55
+ # @return [Note] The resulting object represting created resource.
56
56
  def create(note)
57
57
  validate_type!(note)
58
58
 
@@ -61,33 +61,33 @@ module BaseCRM
61
61
 
62
62
  Note.new(root[:data])
63
63
  end
64
-
64
+
65
65
 
66
66
  # Retrieve a single note
67
- #
67
+ #
68
68
  # get '/notes/{id}'
69
69
  #
70
70
  # Returns a single note available to the user, according to the unique note ID provided
71
71
  # If the note ID does not exist, this request will return an error
72
72
  #
73
73
  # @param id [Integer] Unique identifier of a Note
74
- # @return [Note] Searched resource object.
74
+ # @return [Note] Searched resource object.
75
75
  def find(id)
76
76
  _, _, root = @client.get("/notes/#{id}")
77
77
 
78
78
  Note.new(root[:data])
79
79
  end
80
-
80
+
81
81
 
82
82
  # Update a note
83
- #
83
+ #
84
84
  # put '/notes/{id}'
85
85
  #
86
86
  # Updates note information
87
87
  # If the note ID does not exist, this request will return an error
88
88
  #
89
- # @param note [Note, Hash] Either object of the Note type or Hash. This object's attributes describe the object to be updated.
90
- # @return [Note] The resulting object represting updated resource.
89
+ # @param note [Note, Hash] Either object of the Note type or Hash. This object's attributes describe the object to be updated.
90
+ # @return [Note] The resulting object represting updated resource.
91
91
  def update(note)
92
92
  validate_type!(note)
93
93
  params = extract_params!(note, :id)
@@ -98,10 +98,10 @@ module BaseCRM
98
98
 
99
99
  Note.new(root[:data])
100
100
  end
101
-
101
+
102
102
 
103
103
  # Delete a note
104
- #
104
+ #
105
105
  # delete '/notes/{id}'
106
106
  #
107
107
  # Delete an existing note
@@ -114,7 +114,7 @@ module BaseCRM
114
114
  status, _, _ = @client.delete("/notes/#{id}")
115
115
  status == 204
116
116
  end
117
-
117
+
118
118
 
119
119
  private
120
120
  def validate_type!(note)
@@ -126,7 +126,7 @@ module BaseCRM
126
126
  raise ArgumentError, "one of required attributes is missing. Expected: #{args.join(',')}" if params.count != args.length
127
127
  params
128
128
  end
129
-
129
+
130
130
  def sanitize(note)
131
131
  note.to_h.select { |k, _| OPTS_KEYS_TO_PERSIST.include?(k) }
132
132
  end