basecrm 0.1.2 → 1.0.0
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 +4 -4
- data/LICENSE +2 -2
- data/README.md +273 -17
- data/lib/basecrm.rb +185 -1
- data/lib/basecrm/configuration.rb +59 -0
- data/lib/basecrm/envelope.rb +7 -0
- data/lib/basecrm/errors.rb +65 -0
- data/lib/basecrm/http_client.rb +91 -0
- data/lib/basecrm/middlewares/oauth_bearer_token.rb +18 -0
- data/lib/basecrm/middlewares/raise_error.rb +31 -0
- data/lib/basecrm/model.rb +6 -0
- data/lib/basecrm/models/account.rb +31 -0
- data/lib/basecrm/models/address.rb +22 -0
- data/lib/basecrm/models/associated_contact.rb +19 -0
- data/lib/basecrm/models/contact.rb +88 -0
- data/lib/basecrm/models/deal.rb +58 -0
- data/lib/basecrm/models/lead.rb +79 -0
- data/lib/basecrm/models/loss_reason.rb +22 -0
- data/lib/basecrm/models/note.rb +28 -0
- data/lib/basecrm/models/pipeline.rb +19 -0
- data/lib/basecrm/models/source.rb +22 -0
- data/lib/basecrm/models/stage.rb +34 -0
- data/lib/basecrm/models/tag.rb +25 -0
- data/lib/basecrm/models/task.rb +46 -0
- data/lib/basecrm/models/user.rb +31 -0
- data/lib/basecrm/paginated_resource.rb +32 -0
- data/lib/basecrm/services/accounts_service.rb +33 -0
- data/lib/basecrm/services/associated_contacts_service.rb +91 -0
- data/lib/basecrm/services/contacts_service.rb +138 -0
- data/lib/basecrm/services/deals_service.rb +137 -0
- data/lib/basecrm/services/leads_service.rb +140 -0
- data/lib/basecrm/services/loss_reasons_service.rb +133 -0
- data/lib/basecrm/services/notes_service.rb +134 -0
- data/lib/basecrm/services/pipelines_service.rb +50 -0
- data/lib/basecrm/services/sources_service.rb +133 -0
- data/lib/basecrm/services/stages_service.rb +52 -0
- data/lib/basecrm/services/tags_service.rb +132 -0
- data/lib/basecrm/services/tasks_service.rb +141 -0
- data/lib/basecrm/services/users_service.rb +83 -0
- data/lib/basecrm/version.rb +3 -0
- data/spec/factories/associated_contact.rb +14 -0
- data/spec/factories/contact.rb +27 -0
- data/spec/factories/deal.rb +17 -0
- data/spec/factories/lead.rb +26 -0
- data/spec/factories/loss_reason.rb +11 -0
- data/spec/factories/note.rb +13 -0
- data/spec/factories/source.rb +11 -0
- data/spec/factories/tag.rb +12 -0
- data/spec/factories/task.rb +15 -0
- data/spec/services/accounts_service_spec.rb +16 -0
- data/spec/services/associated_contacts_service_spec.rb +43 -0
- data/spec/services/contacts_service_spec.rb +58 -0
- data/spec/services/deals_service_spec.rb +58 -0
- data/spec/services/leads_service_spec.rb +58 -0
- data/spec/services/loss_reasons_service_spec.rb +58 -0
- data/spec/services/notes_service_spec.rb +58 -0
- data/spec/services/pipelines_service_spec.rb +23 -0
- data/spec/services/sources_service_spec.rb +58 -0
- data/spec/services/stages_service_spec.rb +23 -0
- data/spec/services/tags_service_spec.rb +58 -0
- data/spec/services/tasks_service_spec.rb +58 -0
- data/spec/services/users_service_spec.rb +39 -0
- data/spec/spec_helper.rb +24 -12
- data/spec/support/client_helpers.rb +19 -0
- metadata +160 -71
- data/.gitignore +0 -20
- data/.rspec +0 -2
- data/.travis.yml +0 -6
- data/Gemfile +0 -4
- data/Rakefile +0 -8
- data/basecrm.gemspec +0 -23
- data/lib/base_crm.rb +0 -24
- data/lib/base_crm/account.rb +0 -11
- data/lib/base_crm/api_client_ext.rb +0 -6
- data/lib/base_crm/config.rb +0 -21
- data/lib/base_crm/contact.rb +0 -44
- data/lib/base_crm/custom_fieldable.rb +0 -32
- data/lib/base_crm/deal.rb +0 -50
- data/lib/base_crm/forecasting.rb +0 -12
- data/lib/base_crm/lead.rb +0 -36
- data/lib/base_crm/note.rb +0 -15
- data/lib/base_crm/noteable.rb +0 -15
- data/lib/base_crm/related_object_scope.rb +0 -35
- data/lib/base_crm/resource.rb +0 -14
- data/lib/base_crm/session.rb +0 -48
- data/lib/base_crm/source.rb +0 -14
- data/lib/base_crm/task.rb +0 -16
- data/lib/base_crm/taskable.rb +0 -15
- data/lib/base_crm/version.rb +0 -3
- data/spec/base_crm/account_spec.rb +0 -20
- data/spec/base_crm/contact_spec.rb +0 -92
- data/spec/base_crm/deal_spec.rb +0 -138
- data/spec/base_crm/forecasting_spec.rb +0 -34
- data/spec/base_crm/lead_spec.rb +0 -63
- data/spec/base_crm/note_spec.rb +0 -20
- data/spec/base_crm/resource_mixin_spec.rb +0 -26
- data/spec/base_crm/session_spec.rb +0 -97
- data/spec/base_crm/source_spec.rb +0 -20
- data/spec/base_crm/task_spec.rb +0 -21
- data/spec/support/noteable_shared_examples.rb +0 -64
- data/spec/support/taskable_shared_examples.rb +0 -69
@@ -0,0 +1,58 @@
|
|
1
|
+
# WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
|
2
|
+
|
3
|
+
module BaseCRM
|
4
|
+
class Deal < Model
|
5
|
+
# @!attribute [r] created_at
|
6
|
+
# @return [DateTime] Date and time that the deal was created in UTC (ISO8601 format).
|
7
|
+
# attr_reader :created_at
|
8
|
+
# @!attribute [r] creator_id
|
9
|
+
# @return [Integer] Unique identifier of the user who created the deal.
|
10
|
+
# attr_reader :creator_id
|
11
|
+
# @!attribute [r] id
|
12
|
+
# @return [Integer] Unique identifier of the deal.
|
13
|
+
# attr_reader :id
|
14
|
+
# @!attribute [r] organization_id
|
15
|
+
# @return [Integer] Unique identifier of an organization.
|
16
|
+
# attr_reader :organization_id
|
17
|
+
# @!attribute [r] updated_at
|
18
|
+
# @return [DateTime] Date and time of the last update on the deal in UTC (ISO8601 format).
|
19
|
+
# attr_reader :updated_at
|
20
|
+
|
21
|
+
# @!attribute [rw] contact_id
|
22
|
+
# @return [Integer] Unique identifier of a primary contact.
|
23
|
+
# attr_accessor :contact_id
|
24
|
+
# @!attribute [rw] currency
|
25
|
+
# @return [String] Currency of the deal, specified in 3-character currency code (ISO4217) format.
|
26
|
+
# attr_accessor :currency
|
27
|
+
# @!attribute [rw] custom_fields
|
28
|
+
# @return [Hash] Custom fields are key-value data attached to a deal. See more at [Custom Fields](/docs/rest/articles/requests#custom_fields).
|
29
|
+
# attr_accessor :custom_fields
|
30
|
+
# @!attribute [rw] dropbox_email
|
31
|
+
# @return [String] Dropbox email connected with the deal.
|
32
|
+
# attr_accessor :dropbox_email
|
33
|
+
# @!attribute [rw] hot
|
34
|
+
# @return [Boolean] Indicator of whether or not the deal is hot.
|
35
|
+
# attr_accessor :hot
|
36
|
+
# @!attribute [rw] loss_reason_id
|
37
|
+
# @return [Integer] Reason why the deal was lost.
|
38
|
+
# attr_accessor :loss_reason_id
|
39
|
+
# @!attribute [rw] name
|
40
|
+
# @return [String] Name of the deal.
|
41
|
+
# attr_accessor :name
|
42
|
+
# @!attribute [rw] owner_id
|
43
|
+
# @return [Integer] Unique identifier of the user that the deal is assigned to.
|
44
|
+
# attr_accessor :owner_id
|
45
|
+
# @!attribute [rw] source_id
|
46
|
+
# @return [Integer] Unique identifier of the Source.
|
47
|
+
# attr_accessor :source_id
|
48
|
+
# @!attribute [rw] stage_id
|
49
|
+
# @return [Integer] Unique identifier of the deal's current stage in the pipeline.
|
50
|
+
# attr_accessor :stage_id
|
51
|
+
# @!attribute [rw] tags
|
52
|
+
# @return [Array<String>] An array of tags for a deal. See more at [Tags](/docs/rest/articles/requests#tags).
|
53
|
+
# attr_accessor :tags
|
54
|
+
# @!attribute [rw] value
|
55
|
+
# @return [Integer] Value of the deal in a currency specified in the `currency` field.
|
56
|
+
# attr_accessor :value
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
|
2
|
+
|
3
|
+
module BaseCRM
|
4
|
+
class Lead < Model
|
5
|
+
# @!attribute [r] created_at
|
6
|
+
# @return [DateTime] Date and time of the creation in UTC (ISO8601 format).
|
7
|
+
# attr_reader :created_at
|
8
|
+
# @!attribute [r] creator_id
|
9
|
+
# @return [Integer] Unique identifier of the user who created the lead.
|
10
|
+
# attr_reader :creator_id
|
11
|
+
# @!attribute [r] id
|
12
|
+
# @return [Integer] Unique identifier of the lead.
|
13
|
+
# attr_reader :id
|
14
|
+
# @!attribute [r] updated_at
|
15
|
+
# @return [DateTime] Date and time of the last update in UTC (ISO8601 format).
|
16
|
+
# attr_reader :updated_at
|
17
|
+
|
18
|
+
# @!attribute [rw] address
|
19
|
+
# @return [Address]
|
20
|
+
# attr_accessor :address
|
21
|
+
# @!attribute [rw] custom_fields
|
22
|
+
# @return [Hash] Custom fields are a either a single key-value pair attached to a lead or a set of key-value pairs attached to a lead. See more at [Custom Fields](/docs/rest/articles/requests#custom_fields).
|
23
|
+
# attr_accessor :custom_fields
|
24
|
+
# @!attribute [rw] description
|
25
|
+
# @return [String] Lead description.
|
26
|
+
# attr_accessor :description
|
27
|
+
# @!attribute [rw] email
|
28
|
+
# @return [String] Lead's email.
|
29
|
+
# attr_accessor :email
|
30
|
+
# @!attribute [rw] facebook
|
31
|
+
# @return [String] Lead's Facebook nickname.
|
32
|
+
# attr_accessor :facebook
|
33
|
+
# @!attribute [rw] fax
|
34
|
+
# @return [String] Lead's fax number.
|
35
|
+
# attr_accessor :fax
|
36
|
+
# @!attribute [rw] first_name
|
37
|
+
# @return [String] First name of the lead.
|
38
|
+
# attr_accessor :first_name
|
39
|
+
# @!attribute [rw] industry
|
40
|
+
# @return [String] Organization's industry.
|
41
|
+
# attr_accessor :industry
|
42
|
+
# @!attribute [rw] last_name
|
43
|
+
# @return [String] Last name of the lead. Required unless `organization_name` field is provided.
|
44
|
+
# attr_accessor :last_name
|
45
|
+
# @!attribute [rw] linkedin
|
46
|
+
# @return [String] Lead's Linkedin nickname.
|
47
|
+
# attr_accessor :linkedin
|
48
|
+
# @!attribute [rw] mobile
|
49
|
+
# @return [String] Lead's mobile phone number.
|
50
|
+
# attr_accessor :mobile
|
51
|
+
# @!attribute [rw] organization_name
|
52
|
+
# @return [String] Organization name of the lead. Required unless `last_name` field is provided.
|
53
|
+
# attr_accessor :organization_name
|
54
|
+
# @!attribute [rw] owner_id
|
55
|
+
# @return [Integer] Unique identifier of the user who currently owns the lead.
|
56
|
+
# attr_accessor :owner_id
|
57
|
+
# @!attribute [rw] phone
|
58
|
+
# @return [String] Lead's phone number.
|
59
|
+
# attr_accessor :phone
|
60
|
+
# @!attribute [rw] skype
|
61
|
+
# @return [String] Lead's Skype nickname.
|
62
|
+
# attr_accessor :skype
|
63
|
+
# @!attribute [rw] status
|
64
|
+
# @return [String] Status of the lead.
|
65
|
+
# attr_accessor :status
|
66
|
+
# @!attribute [rw] tags
|
67
|
+
# @return [Array<String>] An array of tags for a lead. See more at [Tags](/docs/rest/articles/requests#tags).
|
68
|
+
# attr_accessor :tags
|
69
|
+
# @!attribute [rw] title
|
70
|
+
# @return [String] Job title of the lead.
|
71
|
+
# attr_accessor :title
|
72
|
+
# @!attribute [rw] twitter
|
73
|
+
# @return [String] Lead's Twitter handle.
|
74
|
+
# attr_accessor :twitter
|
75
|
+
# @!attribute [rw] website
|
76
|
+
# @return [String] Lead's website.
|
77
|
+
# attr_accessor :website
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
|
2
|
+
|
3
|
+
module BaseCRM
|
4
|
+
class LossReason < Model
|
5
|
+
# @!attribute [r] created_at
|
6
|
+
# @return [DateTime] Date and time of creation in UTC ISO8601 format.
|
7
|
+
# attr_reader :created_at
|
8
|
+
# @!attribute [r] creator_id
|
9
|
+
# @return [Integer] Unique identifier of the user the loss reason was created by.
|
10
|
+
# attr_reader :creator_id
|
11
|
+
# @!attribute [r] id
|
12
|
+
# @return [Integer] Unique identifier of the loss reason.
|
13
|
+
# attr_reader :id
|
14
|
+
# @!attribute [r] updated_at
|
15
|
+
# @return [DateTime] Date and time of the last update in UTC ISO8601 format.
|
16
|
+
# attr_reader :updated_at
|
17
|
+
|
18
|
+
# @!attribute [rw] name
|
19
|
+
# @return [String] Human-friendly loss reason explanation.
|
20
|
+
# attr_accessor :name
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
|
2
|
+
|
3
|
+
module BaseCRM
|
4
|
+
class Note < Model
|
5
|
+
# @!attribute [r] created_at
|
6
|
+
# @return [DateTime] Date and time of creation in UTC (ISO8601 format).
|
7
|
+
# attr_reader :created_at
|
8
|
+
# @!attribute [r] creator_id
|
9
|
+
# @return [Integer] Unique identifier of the user that created the note.
|
10
|
+
# attr_reader :creator_id
|
11
|
+
# @!attribute [r] id
|
12
|
+
# @return [Integer] Unique identifier of the note.
|
13
|
+
# attr_reader :id
|
14
|
+
# @!attribute [r] updated_at
|
15
|
+
# @return [DateTime] Date and time of the last update in UTC (ISO8601 format).
|
16
|
+
# attr_reader :updated_at
|
17
|
+
|
18
|
+
# @!attribute [rw] content
|
19
|
+
# @return [String] Content of the note.
|
20
|
+
# attr_accessor :content
|
21
|
+
# @!attribute [rw] resource_id
|
22
|
+
# @return [Integer] Unique identifier of the resource the note is attached to.
|
23
|
+
# attr_accessor :resource_id
|
24
|
+
# @!attribute [rw] resource_type
|
25
|
+
# @return [String] Type name of the resource the note is attached to.
|
26
|
+
# attr_accessor :resource_type
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
|
2
|
+
|
3
|
+
module BaseCRM
|
4
|
+
class Pipeline < Model
|
5
|
+
# @!attribute [r] created_at
|
6
|
+
# @return [DateTime] Date and time of creation in UTC ISO8601 format.
|
7
|
+
# attr_reader :created_at
|
8
|
+
# @!attribute [r] id
|
9
|
+
# @return [Integer] The unique identifier of the pipeline.
|
10
|
+
# attr_reader :id
|
11
|
+
# @!attribute [r] updated_at
|
12
|
+
# @return [DateTime] Date and time of last update in UTC ISO8601 format.
|
13
|
+
# attr_reader :updated_at
|
14
|
+
|
15
|
+
# @!attribute [rw] name
|
16
|
+
# @return [String] Human-friendly name of the pipeline.
|
17
|
+
# attr_accessor :name
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
|
2
|
+
|
3
|
+
module BaseCRM
|
4
|
+
class Source < Model
|
5
|
+
# @!attribute [r] created_at
|
6
|
+
# @return [String] Date and time of creation in UTC (ISO 8601 format).
|
7
|
+
# attr_reader :created_at
|
8
|
+
# @!attribute [r] creator_id
|
9
|
+
# @return [Integer] Unique identifier of the user that created the source.
|
10
|
+
# attr_reader :creator_id
|
11
|
+
# @!attribute [r] id
|
12
|
+
# @return [Integer] Unique identifier of the deal source.
|
13
|
+
# attr_reader :id
|
14
|
+
# @!attribute [r] updated_at
|
15
|
+
# @return [String] Date and time of the last update in UTC (ISO 8601 format).
|
16
|
+
# attr_reader :updated_at
|
17
|
+
|
18
|
+
# @!attribute [rw] name
|
19
|
+
# @return [String] Name of the source.
|
20
|
+
# attr_accessor :name
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
|
2
|
+
|
3
|
+
module BaseCRM
|
4
|
+
class Stage < Model
|
5
|
+
# @!attribute [r] created_at
|
6
|
+
# @return [DateTime] Date and time of creation in UTC ISO8601 format.
|
7
|
+
# attr_reader :created_at
|
8
|
+
# @!attribute [r] id
|
9
|
+
# @return [Integer] The unique identifier of the stage.
|
10
|
+
# attr_reader :id
|
11
|
+
# @!attribute [r] updated_at
|
12
|
+
# @return [DateTime] Date and time of last update in UTC ISO8601 format.
|
13
|
+
# attr_reader :updated_at
|
14
|
+
|
15
|
+
# @!attribute [rw] active
|
16
|
+
# @return [Boolean] Indicator whether or not the stage contains finalized deals.
|
17
|
+
# attr_accessor :active
|
18
|
+
# @!attribute [rw] category
|
19
|
+
# @return [String] The unique category name of the stage.
|
20
|
+
# attr_accessor :category
|
21
|
+
# @!attribute [rw] likelihood
|
22
|
+
# @return [Integer] The likelihood that a deal will be won, set for the stage as percentage.
|
23
|
+
# attr_accessor :likelihood
|
24
|
+
# @!attribute [rw] name
|
25
|
+
# @return [String] Human-friendly name of the stage.
|
26
|
+
# attr_accessor :name
|
27
|
+
# @!attribute [rw] pipeline_id
|
28
|
+
# @return [Integer] Unique identifier of the pipeline that contains this stage.
|
29
|
+
# attr_accessor :pipeline_id
|
30
|
+
# @!attribute [rw] position
|
31
|
+
# @return [Integer] The stage's position in the pipeline.
|
32
|
+
# attr_accessor :position
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
|
2
|
+
|
3
|
+
module BaseCRM
|
4
|
+
class Tag < Model
|
5
|
+
# @!attribute [r] created_at
|
6
|
+
# @return [DateTime] Date and time of creation in UTC (ISO8601 format).
|
7
|
+
# attr_reader :created_at
|
8
|
+
# @!attribute [r] creator_id
|
9
|
+
# @return [Integer] User ID of the tag's creator.
|
10
|
+
# attr_reader :creator_id
|
11
|
+
# @!attribute [r] id
|
12
|
+
# @return [Integer] Unique identifier of the tag.
|
13
|
+
# attr_reader :id
|
14
|
+
# @!attribute [r] updated_at
|
15
|
+
# @return [DateTime] Date and time of the last update in UTC (ISO8601 format).
|
16
|
+
# attr_reader :updated_at
|
17
|
+
|
18
|
+
# @!attribute [rw] name
|
19
|
+
# @return [String] Name of the tag.
|
20
|
+
# attr_accessor :name
|
21
|
+
# @!attribute [rw] resource_type
|
22
|
+
# @return [String] Type name of the resource the tag is attached to.
|
23
|
+
# attr_accessor :resource_type
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
|
2
|
+
|
3
|
+
module BaseCRM
|
4
|
+
class Task < Model
|
5
|
+
# @!attribute [r] completed_at
|
6
|
+
# @return [DateTime] Date and time of the task's completion in UTC (ISO8601 format).
|
7
|
+
# attr_reader :completed_at
|
8
|
+
# @!attribute [r] created_at
|
9
|
+
# @return [DateTime] Date and time of task creation in UTC (ISO8601 format).
|
10
|
+
# attr_reader :created_at
|
11
|
+
# @!attribute [r] creator_id
|
12
|
+
# @return [Integer] Unique identifier of the user who created the task.
|
13
|
+
# attr_reader :creator_id
|
14
|
+
# @!attribute [r] id
|
15
|
+
# @return [Integer] Unique identifier of the task.
|
16
|
+
# attr_reader :id
|
17
|
+
# @!attribute [r] overdue
|
18
|
+
# @return [Boolean] Indicator for whether the task has passed the `due_date` or not.
|
19
|
+
# attr_reader :overdue
|
20
|
+
# @!attribute [r] updated_at
|
21
|
+
# @return [DateTime] Date and time of the last update to the task in UTC (ISO8601 format).
|
22
|
+
# attr_reader :updated_at
|
23
|
+
|
24
|
+
# @!attribute [rw] completed
|
25
|
+
# @return [Boolean] Indicator of whether the task is completed or not.
|
26
|
+
# attr_accessor :completed
|
27
|
+
# @!attribute [rw] content
|
28
|
+
# @return [String] Content of the task.
|
29
|
+
# attr_accessor :content
|
30
|
+
# @!attribute [rw] due_date
|
31
|
+
# @return [DateTime] Date and time of creation in UTC (ISO8601 format).
|
32
|
+
# attr_accessor :due_date
|
33
|
+
# @!attribute [rw] owner_id
|
34
|
+
# @return [Integer] Unique identifier of the user the task is assigned to.
|
35
|
+
# attr_accessor :owner_id
|
36
|
+
# @!attribute [rw] remind_at
|
37
|
+
# @return [DateTime] Date and time that we should send you a reminder in UTC (ISO8601 format).
|
38
|
+
# attr_accessor :remind_at
|
39
|
+
# @!attribute [rw] resource_id
|
40
|
+
# @return [Integer] Unique identifier of the resource the task is attached to.
|
41
|
+
# attr_accessor :resource_id
|
42
|
+
# @!attribute [rw] resource_type
|
43
|
+
# @return [String] Name of the resource type the task is attached to.
|
44
|
+
# attr_accessor :resource_type
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
|
2
|
+
|
3
|
+
module BaseCRM
|
4
|
+
class User < Model
|
5
|
+
# @!attribute [r] confirmed
|
6
|
+
# @return [Boolean] Indicates whether the user's account has been confirmed or not.
|
7
|
+
# attr_reader :confirmed
|
8
|
+
# @!attribute [r] created_at
|
9
|
+
# @return [DateTime] Date and time of creation in UTC (ISO8601 format).
|
10
|
+
# attr_reader :created_at
|
11
|
+
# @!attribute [r] id
|
12
|
+
# @return [Integer] Unique identifier of the user.
|
13
|
+
# attr_reader :id
|
14
|
+
# @!attribute [r] role
|
15
|
+
# @return [String] Role of the user.
|
16
|
+
# attr_reader :role
|
17
|
+
# @!attribute [r] status
|
18
|
+
# @return [String] Status of the user's account. Usually `active`.
|
19
|
+
# attr_reader :status
|
20
|
+
# @!attribute [r] updated_at
|
21
|
+
# @return [DateTime] Date and time of the last update in UTC (ISO8601 format).
|
22
|
+
# attr_reader :updated_at
|
23
|
+
|
24
|
+
# @!attribute [rw] email
|
25
|
+
# @return [String] Email address of the user.
|
26
|
+
# attr_accessor :email
|
27
|
+
# @!attribute [rw] name
|
28
|
+
# @return [String] Full name of the user.
|
29
|
+
# attr_accessor :name
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module BaseCRM
|
2
|
+
class PaginatedResource
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_reader :current_page
|
6
|
+
|
7
|
+
def initialize(service, *args)
|
8
|
+
raise TypeError unless service.respond_to?(:where)
|
9
|
+
|
10
|
+
@service = service
|
11
|
+
@args = args
|
12
|
+
@options = args.last.kind_of?(Hash) ? args.pop : {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def each(&block)
|
16
|
+
return to_enum(:each) unless block_given?
|
17
|
+
|
18
|
+
current_page = 1
|
19
|
+
per_page = 25
|
20
|
+
|
21
|
+
search_options = @options.merge(page: current_page, per_page: per_page)
|
22
|
+
|
23
|
+
until (resources = @service.where(*@args, search_options)).empty?
|
24
|
+
resources.each(&block)
|
25
|
+
current_page += 1
|
26
|
+
search_options[:page] = current_page
|
27
|
+
end
|
28
|
+
|
29
|
+
self
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# WARNING: This code is auto-generated from the BaseCRM API Discovery JSON Schema
|
2
|
+
|
3
|
+
module BaseCRM
|
4
|
+
class AccountsService
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
# Retrieve account details
|
10
|
+
#
|
11
|
+
# get '/accounts/self'
|
12
|
+
#
|
13
|
+
# Returns detailed information about your account
|
14
|
+
#
|
15
|
+
# @return [Account] Resource object.
|
16
|
+
def self
|
17
|
+
_, _, root = @client.get("/accounts/self")
|
18
|
+
Account.new(root[:data])
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
private
|
23
|
+
def validate_type!(account)
|
24
|
+
raise TypeError unless account.is_a?(Account) || account.is_a?(Hash)
|
25
|
+
end
|
26
|
+
|
27
|
+
def extract_params!(account, *args)
|
28
|
+
params = account.to_h.select{ |k, _| args.include?(k) }
|
29
|
+
raise ArgumentError, "one of required attributes is missing. Expected: #{args.join(',')}" if params.count != args.length
|
30
|
+
params
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|