qrapi-wrapper 0.6.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.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/lib/qrapi.rb +79 -0
  3. data/lib/qrapi/client.rb +58 -0
  4. data/lib/qrapi/error_handling_resourceable.rb +22 -0
  5. data/lib/qrapi/mappings/contact_mapping.rb +22 -0
  6. data/lib/qrapi/mappings/distribution_mapping.rb +68 -0
  7. data/lib/qrapi/mappings/division_mapping.rb +27 -0
  8. data/lib/qrapi/mappings/error_mapping.rb +19 -0
  9. data/lib/qrapi/mappings/group_mapping.rb +27 -0
  10. data/lib/qrapi/mappings/library_message_mapping.rb +20 -0
  11. data/lib/qrapi/mappings/mailing_list_mapping.rb +20 -0
  12. data/lib/qrapi/mappings/organization_mapping.rb +19 -0
  13. data/lib/qrapi/mappings/response_export_mapping.rb +14 -0
  14. data/lib/qrapi/mappings/responses_mapping.rb +45 -0
  15. data/lib/qrapi/mappings/survey_mapping.rb +33 -0
  16. data/lib/qrapi/mappings/user_mapping.rb +40 -0
  17. data/lib/qrapi/models/base_model.rb +22 -0
  18. data/lib/qrapi/models/distribution.rb +45 -0
  19. data/lib/qrapi/models/distribution/headers.rb +27 -0
  20. data/lib/qrapi/models/distribution/message.rb +26 -0
  21. data/lib/qrapi/models/distribution/recipients.rb +26 -0
  22. data/lib/qrapi/models/distribution/survey_link.rb +26 -0
  23. data/lib/qrapi/models/division.rb +32 -0
  24. data/lib/qrapi/models/group.rb +31 -0
  25. data/lib/qrapi/models/library_message.rb +27 -0
  26. data/lib/qrapi/models/mailing_list.rb +27 -0
  27. data/lib/qrapi/models/mailing_list/contact.rb +33 -0
  28. data/lib/qrapi/models/organization.rb +29 -0
  29. data/lib/qrapi/models/response.rb +40 -0
  30. data/lib/qrapi/models/response_export.rb +71 -0
  31. data/lib/qrapi/models/survey.rb +45 -0
  32. data/lib/qrapi/models/survey/expiration.rb +25 -0
  33. data/lib/qrapi/models/user.rb +44 -0
  34. data/lib/qrapi/resources/distribution_resource.rb +47 -0
  35. data/lib/qrapi/resources/division_resource.rb +24 -0
  36. data/lib/qrapi/resources/group_resource.rb +44 -0
  37. data/lib/qrapi/resources/library_message_resource.rb +41 -0
  38. data/lib/qrapi/resources/mailing_list_resource.rb +51 -0
  39. data/lib/qrapi/resources/organization_resource.rb +12 -0
  40. data/lib/qrapi/resources/response_export_resource.rb +49 -0
  41. data/lib/qrapi/resources/response_import_resource.rb +26 -0
  42. data/lib/qrapi/resources/survey_resource.rb +27 -0
  43. data/lib/qrapi/resources/user_resource.rb +35 -0
  44. data/lib/qrapi/utils/kartograph_optional_properties.rb +21 -0
  45. data/lib/qrapi/version.rb +3 -0
  46. metadata +271 -0
@@ -0,0 +1,33 @@
1
+ module QRAPI
2
+ class SurveyMapping
3
+ include Kartograph::DSL
4
+
5
+ kartograph do
6
+ mapping Survey
7
+ root_key singular: "result", plural: "elements", scopes: [:read]
8
+
9
+ property :name, scopes: [:read, :update], optional: true
10
+ property :is_active, scopes: [:read, :update], key: "isActive", optional: true
11
+ property :expiration, scopes: [:read, :update], optional: true do
12
+ mapping Survey::Expiration
13
+
14
+ property :start_date, scopes: [:read, :update], key: "startDate"
15
+ property :end_date, scopes: [:read, :update], key: "endDate"
16
+ end
17
+
18
+ scoped :read do
19
+ property :id
20
+ property :name
21
+ property :owner_id, key: "ownerId"
22
+ property :organization_id, key: "organizationId"
23
+ property :creation_date, key: "creationDate"
24
+ property :last_modified, key: "lastModified"
25
+ property :flow
26
+ property :embedded_data, key: "embeddedData"
27
+ property :response_counts, key: "responseCounts"
28
+ property :questions
29
+ property :export_column_map, key: "exportColumnMap"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,40 @@
1
+ module QRAPI
2
+ class UserMapping
3
+ include Kartograph::DSL
4
+
5
+ kartograph do
6
+ mapping User
7
+ root_key singular: "result", plural: "elements", scopes: [:read]
8
+
9
+ property :username, scopes: [:read, :create, :update]
10
+ property :first_name, scopes: [:read, :create, :update], key: "firstName"
11
+ property :last_name, scopes: [:read, :create, :update], key: "lastName"
12
+ property :user_type, scopes: [:read, :create, :update], key: "userType"
13
+ property :language, scopes: [:read, :create, :update]
14
+ property :status, scopes: [:read, :update]
15
+ # property :permissions, scopes: [:read, :update]
16
+
17
+ scoped :read do
18
+ property :id
19
+ property :organization_id, key: "organizationId"
20
+ property :division_id, key: "divisionId"
21
+ property :unsubscribed
22
+ property :account_creation_date, key: "accountCreationDate"
23
+ property :account_expiration_date, key: "accountExpirationDate"
24
+ property :password_last_changed_date, key: "passwordLastChangedDate"
25
+ property :password_expiration_date, key: "passwordExpirationDate"
26
+ property :last_login_date, key: "lastLoginDate"
27
+ property :response_counts, key: "responseCounts"
28
+ end
29
+
30
+ scoped :create do
31
+ property :password, scopes: [:create]
32
+ property :email, scopes: [:create]
33
+ end
34
+
35
+ scoped :create, :update do
36
+ property :division_id, key: "divisionId", optional: true
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,22 @@
1
+ require "virtus"
2
+
3
+ module QRAPI
4
+ class BaseModel
5
+ include Virtus.model
6
+ include Virtus::Equalizer.new(name || inspect)
7
+ include ::ActiveModel::Serialization
8
+
9
+ def inspect
10
+ values = Hash[instance_variables.map { |name| [name, instance_variable_get(name)] }]
11
+ "<#{self.class.name} #{values}>"
12
+ end
13
+
14
+ def created_at
15
+ nil
16
+ end
17
+
18
+ def updated_at
19
+ nil
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,45 @@
1
+ module QRAPI
2
+ class Distribution < BaseModel
3
+ attribute :id
4
+ attribute :parent_distribution_id
5
+ attribute :owner_id
6
+ attribute :organization_id
7
+ attribute :request_status
8
+ attribute :request_type
9
+ attribute :send_date
10
+ attribute :created_date
11
+ attribute :modified_date
12
+ attribute :headers
13
+ attribute :recipients
14
+ attribute :message
15
+ attribute :survey_link
16
+ attribute :stats
17
+
18
+ ##
19
+ # Make the model serializeable by ActiveModelSerializer
20
+ #
21
+ # @return [OpenStruct]
22
+ #
23
+ def self.model_name
24
+ OpenStruct.new(name: "QRAPI::Distribution",
25
+ klass: self,
26
+ singular: "qualtrics_distribution",
27
+ plural: "qualtrics_distributions",
28
+ element: "distribution",
29
+ human: "distribution",
30
+ collection: "qrapi/distributions",
31
+ param_key: "qualtrics_distributions",
32
+ i18n_key: "qrapi/distributions",
33
+ route_key: "qualtrics_distributions",
34
+ singular_route_key: "qualtrics_distribution")
35
+ end
36
+
37
+ def created_at
38
+ creation_date
39
+ end
40
+
41
+ def updated_at
42
+ modified_date
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,27 @@
1
+ module QRAPI
2
+ class Distribution::Headers < BaseModel
3
+ attribute :from_email
4
+ attribute :from_name
5
+ attribute :reply_to_email
6
+ attribute :subject
7
+
8
+ ##
9
+ # Make the model serializeable by ActiveModelSerializer
10
+ #
11
+ # @return [OpenStruct]
12
+ #
13
+ def self.model_name
14
+ OpenStruct.new(name: "QRAPI::MailingList",
15
+ klass: self,
16
+ singular: "qualtrics_distribution_header",
17
+ plural: "qualtrics_distribution_headers",
18
+ element: "distribution_header",
19
+ human: "distribution_header",
20
+ collection: "qrapi/distribution_headers",
21
+ param_key: "qualtrics_distribution_headers",
22
+ i18n_key: "qrapi/distribution_headers",
23
+ route_key: "qualtrics_distribution_headers",
24
+ singular_route_key: "qualtrics_distribution_header")
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ module QRAPI
2
+ class Distribution::Message < BaseModel
3
+ attribute :message_id
4
+ attribute :library_id
5
+ attribute :message_text
6
+
7
+ ##
8
+ # Make the model serializeable by ActiveModelSerializer
9
+ #
10
+ # @return [OpenStruct]
11
+ #
12
+ def self.model_name
13
+ OpenStruct.new(name: "QRAPI::MailingList",
14
+ klass: self,
15
+ singular: "qualtrics_distribution_message",
16
+ plural: "qualtrics_distribution_messages",
17
+ element: "distribution_message",
18
+ human: "distribution_message",
19
+ collection: "qrapi/distribution_messages",
20
+ param_key: "qualtrics_distribution_messages",
21
+ i18n_key: "qrapi/distribution_messages",
22
+ route_key: "qualtrics_distribution_messages",
23
+ singular_route_key: "qualtrics_distribution_message")
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module QRAPI
2
+ class Distribution::Recipients < BaseModel
3
+ attribute :mailing_list_id
4
+ attribute :distribution_recipient_id
5
+ attribute :contact_id
6
+
7
+ ##
8
+ # Make the model serializeable by ActiveModelSerializer
9
+ #
10
+ # @return [OpenStruct]
11
+ #
12
+ def self.model_name
13
+ OpenStruct.new(name: "QRAPI::MailingList",
14
+ klass: self,
15
+ singular: "qualtrics_distribution_recipient",
16
+ plural: "qualtrics_distribution_recipients",
17
+ element: "distribution_recipient",
18
+ human: "distribution_recipient",
19
+ collection: "qrapi/distribution_recipients",
20
+ param_key: "qualtrics_distribution_recipients",
21
+ i18n_key: "qrapi/distribution_recipients",
22
+ route_key: "qualtrics_distribution_recipients",
23
+ singular_route_key: "qualtrics_distribution_recipient")
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module QRAPI
2
+ class Distribution::SurveyLink < BaseModel
3
+ attribute :survey_id
4
+ attribute :expiration_date
5
+ attribute :type
6
+
7
+ ##
8
+ # Make the model serializeable by ActiveModelSerializer
9
+ #
10
+ # @return [OpenStruct]
11
+ #
12
+ def self.model_name
13
+ OpenStruct.new(name: "QRAPI::MailingList",
14
+ klass: self,
15
+ singular: "qualtrics_distribution_survey_link",
16
+ plural: "qualtrics_distribution_survey_links",
17
+ element: "distribution_survey_link",
18
+ human: "distribution_survey_link",
19
+ collection: "qrapi/distribution_survey_links",
20
+ param_key: "qualtrics_distribution_survey_links",
21
+ i18n_key: "qrapi/distribution_survey_links",
22
+ route_key: "qualtrics_distribution_survey_links",
23
+ singular_route_key: "qualtrics_distribution_survey_link")
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ module QRAPI
2
+ class Division < BaseModel
3
+ attribute :id
4
+ attribute :organization_id
5
+ attribute :creator_id
6
+ attribute :name
7
+ attribute :creation_date
8
+ attribute :status
9
+ attribute :response_counts
10
+ attribute :division_admins
11
+ # attribute :permissions
12
+
13
+ ##
14
+ # Make the model serializeable by ActiveModelSerializer
15
+ #
16
+ # @return [OpenStruct]
17
+ #
18
+ def self.model_name
19
+ OpenStruct.new(name: "QRAPI::MailingList",
20
+ klass: self,
21
+ singular: "qualtrics_division",
22
+ plural: "qualtrics_divisions",
23
+ element: "division",
24
+ human: "division",
25
+ collection: "qrapi/divisions",
26
+ param_key: "qualtrics_divisions",
27
+ i18n_key: "qrapi/divisions",
28
+ route_key: "qualtrics_divisions",
29
+ singular_route_key: "qualtrics_division")
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,31 @@
1
+ module QRAPI
2
+ class Group < BaseModel
3
+ attribute :id
4
+ attribute :type
5
+ attribute :organization_id
6
+ attribute :division_id
7
+ attribute :name
8
+ attribute :all_users
9
+ attribute :creation_date
10
+ attribute :creator_id
11
+
12
+ ##
13
+ # Make the model serializeable by ActiveModelSerializer
14
+ #
15
+ # @return [OpenStruct]
16
+ #
17
+ def self.model_name
18
+ OpenStruct.new(name: "QRAPI::MailingList",
19
+ klass: self,
20
+ singular: "qualtrics_group",
21
+ plural: "qualtrics_groups",
22
+ element: "group",
23
+ human: "group",
24
+ collection: "qrapi/groups",
25
+ param_key: "qualtrics_groups",
26
+ i18n_key: "qrapi/groups",
27
+ route_key: "qualtrics_groups",
28
+ singular_route_key: "qualtrics_group")
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,27 @@
1
+ module QRAPI
2
+ class LibraryMessage < BaseModel
3
+ attribute :id
4
+ attribute :category
5
+ attribute :description
6
+ attribute :messages
7
+
8
+ ##
9
+ # Make the model serializeable by ActiveModelSerializer
10
+ #
11
+ # @return [OpenStruct]
12
+ #
13
+ def self.model_name
14
+ OpenStruct.new(name: "QRAPI::MailingList",
15
+ klass: self,
16
+ singular: "qualtrics_library_message",
17
+ plural: "qualtrics_library_messages",
18
+ element: "library_message",
19
+ human: "library_message",
20
+ collection: "qrapi/library_messages",
21
+ param_key: "qualtrics_library_messages",
22
+ i18n_key: "qrapi/library_messages",
23
+ route_key: "qualtrics_library_messages",
24
+ singular_route_key: "qualtrics_library_message")
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ module QRAPI
2
+ class MailingList < BaseModel
3
+ attribute :id
4
+ attribute :library_id
5
+ attribute :name
6
+ attribute :category
7
+
8
+ ##
9
+ # Make the model serializeable by ActiveModelSerializer
10
+ #
11
+ # @return [OpenStruct]
12
+ #
13
+ def self.model_name
14
+ OpenStruct.new(name: "QRAPI::MailingList",
15
+ klass: self,
16
+ singular: "qualtrics_mailing_list",
17
+ plural: "qualtrics_mailing_lists",
18
+ element: "mailing_list",
19
+ human: "mailing_list",
20
+ collection: "qrapi/mailing_lists",
21
+ param_key: "qualtrics_mailing_lists",
22
+ i18n_key: "qrapi/mailing_lists",
23
+ route_key: "qualtrics_mailing_lists",
24
+ singular_route_key: "qualtrics_mailing_list")
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,33 @@
1
+ module QRAPI
2
+ class MailingList::Contact < BaseModel
3
+ attribute :id
4
+ attribute :first_name
5
+ attribute :last_name
6
+ attribute :email
7
+ attribute :external_data_reference
8
+ attribute :embedded_data
9
+ attribute :language
10
+ attribute :unsubscribed
11
+ attribute :response_history
12
+ attribute :email_history
13
+
14
+ ##
15
+ # Make the model serializeable by ActiveModelSerializer
16
+ #
17
+ # @return [OpenStruct]
18
+ #
19
+ def self.model_name
20
+ OpenStruct.new(name: "QRAPI::MailingList::Contact",
21
+ klass: self,
22
+ singular: "qualtrics_mailing_list_contact",
23
+ plural: "qualtrics_mailing_list_contacts",
24
+ element: "mailing_list_contacts",
25
+ human: "mailing_list_contact",
26
+ collection: "qrapi/mailing_list_contacts",
27
+ param_key: "qualtrics_mailing_list_contacts",
28
+ i18n_key: "qrapi/mailing_list_contacts",
29
+ route_key: "qualtrics_mailing_list_contacts",
30
+ singular_route_key: "qualtrics_mailing_list_contact")
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,29 @@
1
+ module QRAPI
2
+ class Organization < BaseModel
3
+ attribute :id
4
+ attribute :name
5
+ attribute :base_url
6
+ attribute :type
7
+ attribute :status
8
+ attribute :stats
9
+
10
+ ##
11
+ # Make the model serializeable by ActiveModelSerializer
12
+ #
13
+ # @return [OpenStruct]
14
+ #
15
+ def self.model_name
16
+ OpenStruct.new(name: "QRAPI::MailingList",
17
+ klass: self,
18
+ singular: "qualtrics_organization",
19
+ plural: "qualtrics_organizations",
20
+ element: "organization",
21
+ human: "organization",
22
+ collection: "qrapi/organizations",
23
+ param_key: "qualtrics_organizations",
24
+ i18n_key: "qrapi/organizations",
25
+ route_key: "qualtrics_organizations",
26
+ singular_route_key: "qualtrics_organization")
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,40 @@
1
+ module QRAPI
2
+ class Response < BaseModel
3
+ include ::ActiveModel::Serialization
4
+
5
+ attribute :id
6
+ attribute :response_set
7
+ attribute :ip_address
8
+ attribute :start_date
9
+ attribute :end_date
10
+ attribute :last_name
11
+ attribute :first_name
12
+ attribute :email
13
+ attribute :external_data_reference
14
+ attribute :finished
15
+ attribute :status
16
+ attribute :location_latitude
17
+ attribute :location_longitude
18
+ attribute :location_accuracy
19
+ attribute :questions
20
+
21
+ ##
22
+ # Make the model serializeable by ActiveModelSerializer
23
+ #
24
+ # @return [OpenStruct]
25
+ #
26
+ def self.model_name
27
+ OpenStruct.new(name: "QRAPI::Response",
28
+ klass: self,
29
+ singular: "qualtrics_response",
30
+ plural: "qualtrics_responses",
31
+ element: "responses",
32
+ human: "response",
33
+ collection: "qrapi/responses",
34
+ param_key: "qualtrics_responses",
35
+ i18n_key: "qrapi/responses",
36
+ route_key: "qualtrics_responses",
37
+ singular_route_key: "qualtrics_response")
38
+ end
39
+ end
40
+ end