voucherify 5.0.0 → 5.0.1
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/CHANGELOG.md +33 -0
- data/Dockerfile +1 -1
- data/EXAMPLES.md +3 -3
- data/Gemfile.lock +4 -4
- data/README.md +13 -0
- data/__tests__/lib/voucherify_data.rb +9 -0
- data/__tests__/spec/2_campaigns_spec.rb +1 -1
- data/__tests__/spec/a1_validation_rules_spec.rb +33 -0
- data/docs/ValidationRulesApi.md +65 -0
- data/docs/ValidationRulesAssignmentsCreateRequestBody.md +9 -0
- data/docs/ValidationRulesAssignmentsCreateResponseBody.md +13 -0
- data/lib/VoucherifySdk/api/validation_rules_api.rb +73 -0
- data/lib/VoucherifySdk/models/validation_rules_assignments_create_request_body.rb +262 -0
- data/lib/VoucherifySdk/models/validation_rules_assignments_create_response_body.rb +361 -0
- data/lib/VoucherifySdk/version.rb +1 -1
- data/lib/VoucherifySdk.rb +2 -0
- metadata +9 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd34d559319e8b5ce1fcca10a839561e7b49a7d7c69a946645711f80f1c1eb56
|
|
4
|
+
data.tar.gz: a105ae29df94ac6b604da3b970ec131d55569e2199fd4436ae56c535c6d0bdba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d82ec6f45c519ef2fc7d8b51f0949be3709fa278a51299df4ee18580656e363d1a9095cf7bd3496b3d411f244dbac9c116718c41ae9c5628bad7c03213a214ab
|
|
7
|
+
data.tar.gz: f73be1e93ee6f114bc54b35a4e7b8813eddaabe4258520c0d98491062d32b6b65e4af55ed8a26c72f7ced173cd36fd4de76ecb3f55f819229cfc2bc98b201901
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
- **2022-01-18** - `4.1.0` - Async Actions support.
|
|
2
|
+
- **2021-06-14** - `4.0.0` - Bumped required ruby version, bumped dependencies, added `Consents` API support, remove deprecated `URI.escape`.
|
|
3
|
+
- **2020-03-09** - `3.0.0` - Bumped required ruby version, bumped dependencies, added `list` method in Customers module.
|
|
4
|
+
- **2019-06-19** - `2.4.0` - Added support for custom API endpoint, that allows to connect to projects created in specific Voucherify region.
|
|
5
|
+
- **2019-05-09** - `2.3.0` - Added `create_publication` method in Distributions module.
|
|
6
|
+
- **2019-04-23** - `2.2.0` - Loyalties API, Rewards API, Orders API.
|
|
7
|
+
- **2019-02-19** - `2.1.1` - Treat `referral` as optional in custom events. Added new method for custom event tracking.
|
|
8
|
+
- **2019-02-19** - `2.1.0` - Handle `referral` in custom events tracking.
|
|
9
|
+
- **2018-12-27** - `2.0.0` - Business validation rules.
|
|
10
|
+
- **2018-09-05** - `1.6.1` - Request timeout settings
|
|
11
|
+
- **2017-11-16** - `1.6.0` - Expose promotion API, Redemptions and Validations namespace update
|
|
12
|
+
- **2017-11-16** - `1.5.0` - Expose events API
|
|
13
|
+
- **2017-05-07** - `1.4.0` - Segments, Validation rules, API Versioning
|
|
14
|
+
- **2017-03-22** - `1.3.0` - improved error handling
|
|
15
|
+
- **2017-01-04** - `1.2.0` - added [import vouchers](#import-vouchers) method.
|
|
16
|
+
- **2016-12-29** - `1.1.0` - introduced [campaigns api](#campaigns-api) and [products api](#products-api).
|
|
17
|
+
- **2016-12-15** - `1.0.0` - introduced namespaces, unified method names, updated README. Migration from versions 0.x required [migration from version 0.x](#migration-from-0x)
|
|
18
|
+
- **2016-12-02** - `0.8.2` - support gift vouchers in utils, fix price and discount calculations for amount discounts
|
|
19
|
+
- **2016-10-03** - `0.8.1` - publish update
|
|
20
|
+
- **2016-08-02** - `0.8.0` - validate voucher
|
|
21
|
+
- **2016-07-18** - `0.7.0` - voucher udpate
|
|
22
|
+
- **2016-07-05** - `0.6.0` - new utils module
|
|
23
|
+
- **2016-06-16** - `0.5.0` - unified naming convention
|
|
24
|
+
- **2016-06-12** - `0.4.0` - new customer sdk methods
|
|
25
|
+
- **2016-05-24** - `0.3.0` - new publish structure
|
|
26
|
+
- **2016-04-27** - `0.2.0` - rollback redemption
|
|
27
|
+
- **2016-04-13** - `0.1.3` - bugfix in redeem()
|
|
28
|
+
- **2016-04-13** - `0.1.2` - removed dependency to `pry`
|
|
29
|
+
- **2016-04-12** - `0.1.1` - minor gemspec changes
|
|
30
|
+
- **2016-04-12** - `0.1.0` - First version:
|
|
31
|
+
- Authentication
|
|
32
|
+
- Voucher information: *retrieve voucher*, *list vouchers*, *retrieve redemptions*, *list redemptions*
|
|
33
|
+
- Voucher operations: *redeem voucher*, *publish voucher*, *create voucher*, *enable/disable voucher*
|
data/Dockerfile
CHANGED
data/EXAMPLES.md
CHANGED
|
@@ -67,15 +67,15 @@ gem build VoucherifySdk.gemspec
|
|
|
67
67
|
Then either install the gem locally:
|
|
68
68
|
|
|
69
69
|
```shell
|
|
70
|
-
gem install ./VoucherifySdk-
|
|
70
|
+
gem install ./VoucherifySdk-5.0.1.gem
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
(for development, run `gem install --dev ./VoucherifySdk-
|
|
73
|
+
(for development, run `gem install --dev ./VoucherifySdk-5.0.1.gem` to install the development dependencies)
|
|
74
74
|
|
|
75
75
|
Add this to the Gemfile:
|
|
76
76
|
|
|
77
77
|
```shell
|
|
78
|
-
gem 'VoucherifySdk', '~>
|
|
78
|
+
gem 'VoucherifySdk', '~> 5.0.1'
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
Then install dependencies with bundler
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
voucherify (5.0.
|
|
4
|
+
voucherify (5.0.1)
|
|
5
5
|
typhoeus (~> 1.0, >= 1.0.1)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -15,9 +15,9 @@ GEM
|
|
|
15
15
|
ffi (>= 1.15.0)
|
|
16
16
|
ffi (1.16.3)
|
|
17
17
|
jaro_winkler (1.5.6)
|
|
18
|
-
method_source (1.
|
|
18
|
+
method_source (1.1.0)
|
|
19
19
|
parallel (1.24.0)
|
|
20
|
-
parser (3.3.0
|
|
20
|
+
parser (3.3.1.0)
|
|
21
21
|
ast (~> 2.4.1)
|
|
22
22
|
racc
|
|
23
23
|
pry (0.14.2)
|
|
@@ -40,7 +40,7 @@ GEM
|
|
|
40
40
|
rspec-expectations (3.13.0)
|
|
41
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
42
42
|
rspec-support (~> 3.13.0)
|
|
43
|
-
rspec-mocks (3.13.
|
|
43
|
+
rspec-mocks (3.13.1)
|
|
44
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
45
45
|
rspec-support (~> 3.13.0)
|
|
46
46
|
rspec-support (3.13.1)
|
data/README.md
CHANGED
|
@@ -111,6 +111,16 @@ Read more about how to Contribute to Voucherify Ruby SDK by visiting main repo [
|
|
|
111
111
|
|
|
112
112
|
Remember that this SDK is auto generated (except of the tests) so changes made here will be overwritten by generator.
|
|
113
113
|
|
|
114
|
+
## 📅 Changelog
|
|
115
|
+
|
|
116
|
+
- **2024-05-08** - `5.0.1` - Added support for [Create validation rule assignment](https://docs.voucherify.io/reference/create-validation-rule-assignment)
|
|
117
|
+
|
|
118
|
+
- **2024-03-11** - `5.0.0` - The new version of the SKD includes coverage for all the most commonly used Voucherify endpoints and supports typed models.
|
|
119
|
+
|
|
120
|
+
*Previous versions of the API are no longer supported, and we highly recommend upgrading to version 5.0.0, which is now designated as Long-Term Support (LTS).*
|
|
121
|
+
|
|
122
|
+
*Changelog for previous versions could be found in the [CHANGELOG.md file](./CHANGELOG.md)*
|
|
123
|
+
|
|
114
124
|
## 🔐 Documentation for Authorization
|
|
115
125
|
|
|
116
126
|
```ruby
|
|
@@ -254,6 +264,7 @@ Class | Method | HTTP request | Description
|
|
|
254
264
|
*VoucherifySdk::RewardsApi* | [**list_reward_assignments**](docs/RewardsApi.md#list_reward_assignments) | **GET** /v1/rewards/{rewardId}/assignments | List Reward Assignments
|
|
255
265
|
*VoucherifySdk::RewardsApi* | [**update_reward_assignment**](docs/RewardsApi.md#update_reward_assignment) | **PUT** /v1/rewards/{rewardId}/assignments/{assignmentId} | Update Reward Assignment
|
|
256
266
|
*VoucherifySdk::SegmentsApi* | [**delete_segment**](docs/SegmentsApi.md#delete_segment) | **DELETE** /v1/segments/{segmentId} | Delete Segment
|
|
267
|
+
*VoucherifySdk::ValidationRulesApi* | [**create_validation_rule_assignment**](docs/ValidationRulesApi.md#create_validation_rule_assignment) | **POST** /v1/validation-rules/{validationRuleId}/assignments | Create Validation Rules Assignments
|
|
257
268
|
*VoucherifySdk::ValidationRulesApi* | [**create_validation_rules**](docs/ValidationRulesApi.md#create_validation_rules) | **POST** /v1/validation-rules | Create Validation Rules
|
|
258
269
|
*VoucherifySdk::ValidationRulesApi* | [**delete_validation_rule_assignment**](docs/ValidationRulesApi.md#delete_validation_rule_assignment) | **DELETE** /v1/validation-rules/{validationRuleId}/assignments/{assignmentId} | Delete Validation Rule Assignment
|
|
259
270
|
*VoucherifySdk::ValidationRulesApi* | [**delete_validation_rules**](docs/ValidationRulesApi.md#delete_validation_rules) | **DELETE** /v1/validation-rules/{validationRuleId} | Delete Validation Rule
|
|
@@ -877,6 +888,8 @@ Class | Method | HTTP request | Description
|
|
|
877
888
|
- [VoucherifySdk::ValidationRuleBase](docs/ValidationRuleBase.md)
|
|
878
889
|
- [VoucherifySdk::ValidationRuleBaseApplicableTo](docs/ValidationRuleBaseApplicableTo.md)
|
|
879
890
|
- [VoucherifySdk::ValidationRuleBaseError](docs/ValidationRuleBaseError.md)
|
|
891
|
+
- [VoucherifySdk::ValidationRulesAssignmentsCreateRequestBody](docs/ValidationRulesAssignmentsCreateRequestBody.md)
|
|
892
|
+
- [VoucherifySdk::ValidationRulesAssignmentsCreateResponseBody](docs/ValidationRulesAssignmentsCreateResponseBody.md)
|
|
880
893
|
- [VoucherifySdk::ValidationRulesAssignmentsList](docs/ValidationRulesAssignmentsList.md)
|
|
881
894
|
- [VoucherifySdk::ValidationRulesAssignmentsListResponseBody](docs/ValidationRulesAssignmentsListResponseBody.md)
|
|
882
895
|
- [VoucherifySdk::ValidationRulesCreateRequestBody](docs/ValidationRulesCreateRequestBody.md)
|
|
@@ -15,6 +15,7 @@ class VoucherifyData
|
|
|
15
15
|
@loyalty_card = nil
|
|
16
16
|
@product_ids = []
|
|
17
17
|
@sku = nil
|
|
18
|
+
@validation_rule = nil
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
def set_discount_campaign(discount_campaign)
|
|
@@ -37,6 +38,10 @@ class VoucherifyData
|
|
|
37
38
|
@product_ids.push(product_id)
|
|
38
39
|
end
|
|
39
40
|
|
|
41
|
+
def set_validation_rule(validation_rule)
|
|
42
|
+
@validation_rule = validation_rule
|
|
43
|
+
end
|
|
44
|
+
|
|
40
45
|
def get_product_ids
|
|
41
46
|
@product_ids
|
|
42
47
|
end
|
|
@@ -89,6 +94,10 @@ class VoucherifyData
|
|
|
89
94
|
@loyalty_card
|
|
90
95
|
end
|
|
91
96
|
|
|
97
|
+
def get_validation_rule
|
|
98
|
+
@validation_rule
|
|
99
|
+
end
|
|
100
|
+
|
|
92
101
|
def set_loyalty_card(loyalty_card)
|
|
93
102
|
@loyalty_card = loyalty_card
|
|
94
103
|
end
|
|
@@ -14,7 +14,6 @@ RSpec.describe 'Campaigns API', :order => :defined do
|
|
|
14
14
|
$created_promotion_campaign = nil
|
|
15
15
|
$created_loyalty_campaign = nil
|
|
16
16
|
$created_validation_rule_applicable_to = nil
|
|
17
|
-
$created_campaign_with_validation_rule = nil
|
|
18
17
|
|
|
19
18
|
it 'create a validation rule with applicable_to', :order => :first do
|
|
20
19
|
validation_rule = create_validation_rule_applicable_to(@validation_rules_api_instance, @voucherify_data.get_product.id)
|
|
@@ -22,6 +21,7 @@ RSpec.describe 'Campaigns API', :order => :defined do
|
|
|
22
21
|
expect(validation_rule).not_to be_nil
|
|
23
22
|
|
|
24
23
|
$created_validation_rule_applicable_to = validation_rule
|
|
24
|
+
@voucherify_data.set_validation_rule(validation_rule)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
it 'create a discount campaign with applicable_to validation rule', :order => :second do
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require_relative '../lib/config.rb'
|
|
2
|
+
require_relative '../lib/voucherify_data.rb'
|
|
3
|
+
require 'VoucherifySdk'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'Validation Rules API', :order => :defined do
|
|
6
|
+
before(:each) do
|
|
7
|
+
@validation_rules_api_instance = Config.validation_rules_api_instance()
|
|
8
|
+
@voucherify_data = VoucherifyData.instance()
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'create validation rule', :order => :first do
|
|
12
|
+
voucher = @voucherify_data.get_voucher()
|
|
13
|
+
validation_rule = @voucherify_data.get_validation_rule()
|
|
14
|
+
|
|
15
|
+
validationRulesAssignmentsCreateRequestBody = VoucherifySdk::ValidationRulesAssignmentsCreateRequestBody.new({
|
|
16
|
+
related_object_type: "voucher",
|
|
17
|
+
related_object_id: voucher.code
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
created_validation_rule_assignment = @validation_rules_api_instance.create_validation_rule_assignment(validation_rule.id, {
|
|
21
|
+
validation_rules_assignments_create_request_body: validationRulesAssignmentsCreateRequestBody
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
expect(created_validation_rule_assignment).not_to be_nil
|
|
25
|
+
expect(created_validation_rule_assignment.id).not_to be_nil
|
|
26
|
+
expect(created_validation_rule_assignment.created_at).not_to be_nil
|
|
27
|
+
expect(created_validation_rule_assignment.rule_id).to eq(validation_rule.id)
|
|
28
|
+
expect(created_validation_rule_assignment.related_object_id).to eq(voucher.id)
|
|
29
|
+
expect(created_validation_rule_assignment.related_object_type).to eq("voucher")
|
|
30
|
+
expect(created_validation_rule_assignment.object).to eq("validation_rules_assignment")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
data/docs/ValidationRulesApi.md
CHANGED
|
@@ -4,6 +4,7 @@ All URIs are relative to *https://api.voucherify.io*
|
|
|
4
4
|
|
|
5
5
|
| Method | HTTP request | Description |
|
|
6
6
|
| ------ | ------------ | ----------- |
|
|
7
|
+
| [**create_validation_rule_assignment**](ValidationRulesApi.md#create_validation_rule_assignment) | **POST** /v1/validation-rules/{validationRuleId}/assignments | Create Validation Rules Assignments |
|
|
7
8
|
| [**create_validation_rules**](ValidationRulesApi.md#create_validation_rules) | **POST** /v1/validation-rules | Create Validation Rules |
|
|
8
9
|
| [**delete_validation_rule_assignment**](ValidationRulesApi.md#delete_validation_rule_assignment) | **DELETE** /v1/validation-rules/{validationRuleId}/assignments/{assignmentId} | Delete Validation Rule Assignment |
|
|
9
10
|
| [**delete_validation_rules**](ValidationRulesApi.md#delete_validation_rules) | **DELETE** /v1/validation-rules/{validationRuleId} | Delete Validation Rule |
|
|
@@ -14,6 +15,70 @@ All URIs are relative to *https://api.voucherify.io*
|
|
|
14
15
|
| [**update_validation_rule**](ValidationRulesApi.md#update_validation_rule) | **PUT** /v1/validation-rules/{validationRuleId} | Update Validation Rule |
|
|
15
16
|
|
|
16
17
|
|
|
18
|
+
## create_validation_rule_assignment
|
|
19
|
+
|
|
20
|
+
> <ValidationRulesAssignmentsCreateResponseBody> create_validation_rule_assignment(validation_rule_id, opts)
|
|
21
|
+
|
|
22
|
+
Create Validation Rules Assignments
|
|
23
|
+
|
|
24
|
+
Assign validation rule to either one of the following objects: voucher, campaign, promotion tier, earning rule, reward, distribution.
|
|
25
|
+
|
|
26
|
+
### Examples
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
require 'time'
|
|
30
|
+
require 'VoucherifySdk'
|
|
31
|
+
# setup authorization
|
|
32
|
+
VoucherifySdk.configure do |config|
|
|
33
|
+
# Configure API key authorization: X-App-Id
|
|
34
|
+
config.api_key['X-App-Id'] = 'YOUR API KEY'
|
|
35
|
+
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
|
|
36
|
+
# config.api_key_prefix['X-App-Id'] = 'Bearer'
|
|
37
|
+
|
|
38
|
+
# Configure API key authorization: X-App-Token
|
|
39
|
+
config.api_key['X-App-Token'] = 'YOUR API KEY'
|
|
40
|
+
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
|
|
41
|
+
# config.api_key_prefix['X-App-Token'] = 'Bearer'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
api_instance = VoucherifySdk::ValidationRulesApi.new
|
|
45
|
+
validation_rule_id = 'validation_rule_id_example' # String | Unique validation rule ID.
|
|
46
|
+
opts = {
|
|
47
|
+
force: true, # Boolean | If this flag is set to true, the previous assignment with the same data will be deleted and a new one will be added.
|
|
48
|
+
validation_rules_assignments_create_request_body: VoucherifySdk::ValidationRulesAssignmentsCreateRequestBody.new # ValidationRulesAssignmentsCreateRequestBody | Specify the resource that you would like to assign the validation rule to.
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
begin
|
|
52
|
+
# Create Validation Rules Assignments
|
|
53
|
+
result = api_instance.create_validation_rule_assignment(validation_rule_id, opts)
|
|
54
|
+
p result
|
|
55
|
+
rescue VoucherifySdk::ApiError => e
|
|
56
|
+
puts "Error when calling ValidationRulesApi->create_validation_rule_assignment: #{e}"
|
|
57
|
+
end
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Parameters
|
|
61
|
+
|
|
62
|
+
| Name | Type | Description | Notes |
|
|
63
|
+
| ---- | ---- | ----------- | ----- |
|
|
64
|
+
| **validation_rule_id** | **String** | Unique validation rule ID. | |
|
|
65
|
+
| **force** | **Boolean** | If this flag is set to true, the previous assignment with the same data will be deleted and a new one will be added. | [optional] |
|
|
66
|
+
| **validation_rules_assignments_create_request_body** | [**ValidationRulesAssignmentsCreateRequestBody**](ValidationRulesAssignmentsCreateRequestBody.md) | Specify the resource that you would like to assign the validation rule to. | [optional] |
|
|
67
|
+
|
|
68
|
+
### Return type
|
|
69
|
+
|
|
70
|
+
[**ValidationRulesAssignmentsCreateResponseBody**](ValidationRulesAssignmentsCreateResponseBody.md)
|
|
71
|
+
|
|
72
|
+
### Authorization
|
|
73
|
+
|
|
74
|
+
[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token)
|
|
75
|
+
|
|
76
|
+
### HTTP request headers
|
|
77
|
+
|
|
78
|
+
- **Content-Type**: application/json
|
|
79
|
+
- **Accept**: application/json
|
|
80
|
+
|
|
81
|
+
|
|
17
82
|
## create_validation_rules
|
|
18
83
|
|
|
19
84
|
> <ValidationRulesCreateResponseBody> create_validation_rules(opts)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# VoucherifySdk::ValidationRulesAssignmentsCreateRequestBody
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **related_object_type** | **String** | Defines the related object. i.e. `voucher`. | [optional][default to 'voucher'] |
|
|
8
|
+
| **related_object_id** | **String** | Unique related object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. | [optional] |
|
|
9
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# VoucherifySdk::ValidationRulesAssignmentsCreateResponseBody
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **id** | **String** | Validation rule assignment ID. | |
|
|
8
|
+
| **rule_id** | **String** | Validation rule ID. | |
|
|
9
|
+
| **related_object_id** | **String** | The resource ID to which the validation rule was assigned. | |
|
|
10
|
+
| **related_object_type** | **String** | The type of resource to which the validation rule was assigned. | |
|
|
11
|
+
| **created_at** | **Time** | Timestamp representing the date and time when the validation rule assignment was created in ISO 8601 format. | |
|
|
12
|
+
| **object** | **String** | The type of object represented by the ID. | [default to 'validation_rules_assignment'] |
|
|
13
|
+
|
|
@@ -19,6 +19,79 @@ module VoucherifySdk
|
|
|
19
19
|
def initialize(api_client = ApiClient.default)
|
|
20
20
|
@api_client = api_client
|
|
21
21
|
end
|
|
22
|
+
# Create Validation Rules Assignments
|
|
23
|
+
# Assign validation rule to either one of the following objects: voucher, campaign, promotion tier, earning rule, reward, distribution.
|
|
24
|
+
# @param validation_rule_id [String] Unique validation rule ID.
|
|
25
|
+
# @param [Hash] opts the optional parameters
|
|
26
|
+
# @option opts [Boolean] :force If this flag is set to true, the previous assignment with the same data will be deleted and a new one will be added.
|
|
27
|
+
# @option opts [ValidationRulesAssignmentsCreateRequestBody] :validation_rules_assignments_create_request_body Specify the resource that you would like to assign the validation rule to.
|
|
28
|
+
# @return [ValidationRulesAssignmentsCreateResponseBody]
|
|
29
|
+
def create_validation_rule_assignment(validation_rule_id, opts = {})
|
|
30
|
+
data, _status_code, _headers = create_validation_rule_assignment_with_http_info(validation_rule_id, opts)
|
|
31
|
+
data
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Create Validation Rules Assignments
|
|
35
|
+
# Assign validation rule to either one of the following objects: voucher, campaign, promotion tier, earning rule, reward, distribution.
|
|
36
|
+
# @param validation_rule_id [String] Unique validation rule ID.
|
|
37
|
+
# @param [Hash] opts the optional parameters
|
|
38
|
+
# @option opts [Boolean] :force If this flag is set to true, the previous assignment with the same data will be deleted and a new one will be added.
|
|
39
|
+
# @option opts [ValidationRulesAssignmentsCreateRequestBody] :validation_rules_assignments_create_request_body Specify the resource that you would like to assign the validation rule to.
|
|
40
|
+
# @return [Array<(ValidationRulesAssignmentsCreateResponseBody, Integer, Hash)>] ValidationRulesAssignmentsCreateResponseBody data, response status code and response headers
|
|
41
|
+
private def create_validation_rule_assignment_with_http_info(validation_rule_id, opts = {})
|
|
42
|
+
if @api_client.config.debugging
|
|
43
|
+
@api_client.config.logger.debug 'Calling API: ValidationRulesApi.create_validation_rule_assignment ...'
|
|
44
|
+
end
|
|
45
|
+
# verify the required parameter 'validation_rule_id' is set
|
|
46
|
+
if @api_client.config.client_side_validation && validation_rule_id.nil?
|
|
47
|
+
fail ArgumentError, "Missing the required parameter 'validation_rule_id' when calling ValidationRulesApi.create_validation_rule_assignment"
|
|
48
|
+
end
|
|
49
|
+
# resource path
|
|
50
|
+
local_var_path = '/v1/validation-rules/{validationRuleId}/assignments'.sub('{' + 'validationRuleId' + '}', CGI.escape(validation_rule_id.to_s))
|
|
51
|
+
|
|
52
|
+
# query parameters
|
|
53
|
+
query_params = opts[:query_params] || {}
|
|
54
|
+
query_params[:'force'] = opts[:'force'] if !opts[:'force'].nil?
|
|
55
|
+
|
|
56
|
+
# header parameters
|
|
57
|
+
header_params = opts[:header_params] || {}
|
|
58
|
+
# HTTP header 'Accept' (if needed)
|
|
59
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
|
60
|
+
# HTTP header 'Content-Type'
|
|
61
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
62
|
+
if !content_type.nil?
|
|
63
|
+
header_params['Content-Type'] = content_type
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# form parameters
|
|
67
|
+
form_params = opts[:form_params] || {}
|
|
68
|
+
|
|
69
|
+
# http body (model)
|
|
70
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'validation_rules_assignments_create_request_body'])
|
|
71
|
+
|
|
72
|
+
# return_type
|
|
73
|
+
return_type = opts[:debug_return_type] || 'ValidationRulesAssignmentsCreateResponseBody'
|
|
74
|
+
|
|
75
|
+
# auth_names
|
|
76
|
+
auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token']
|
|
77
|
+
|
|
78
|
+
new_options = opts.merge(
|
|
79
|
+
:operation => :"ValidationRulesApi.create_validation_rule_assignment",
|
|
80
|
+
:header_params => header_params,
|
|
81
|
+
:query_params => query_params,
|
|
82
|
+
:form_params => form_params,
|
|
83
|
+
:body => post_body,
|
|
84
|
+
:auth_names => auth_names,
|
|
85
|
+
:return_type => return_type
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
|
89
|
+
if @api_client.config.debugging
|
|
90
|
+
@api_client.config.logger.debug "API called: ValidationRulesApi#create_validation_rule_assignment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
91
|
+
end
|
|
92
|
+
return data, status_code, headers
|
|
93
|
+
end
|
|
94
|
+
|
|
22
95
|
# Create Validation Rules
|
|
23
96
|
# Create validation rules.
|
|
24
97
|
# @param [Hash] opts the optional parameters
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Voucherify API
|
|
3
|
+
|
|
4
|
+
#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: v2018-08-01
|
|
7
|
+
Contact: support@voucherify.io
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
OpenAPI Generator version: 7.0.1
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module VoucherifySdk
|
|
17
|
+
# Request body schema for **POST** `/validation-rules/{validationRuleId}/assignments`.
|
|
18
|
+
class ValidationRulesAssignmentsCreateRequestBody
|
|
19
|
+
# Defines the related object. i.e. `voucher`.
|
|
20
|
+
attr_accessor :related_object_type
|
|
21
|
+
|
|
22
|
+
# Unique related object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher.
|
|
23
|
+
attr_accessor :related_object_id
|
|
24
|
+
|
|
25
|
+
class EnumAttributeValidator
|
|
26
|
+
attr_reader :datatype
|
|
27
|
+
attr_reader :allowable_values
|
|
28
|
+
|
|
29
|
+
def initialize(datatype, allowable_values)
|
|
30
|
+
@allowable_values = allowable_values.map do |value|
|
|
31
|
+
case datatype.to_s
|
|
32
|
+
when /Integer/i
|
|
33
|
+
value.to_i
|
|
34
|
+
when /Float/i
|
|
35
|
+
value.to_f
|
|
36
|
+
else
|
|
37
|
+
value
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def valid?(value)
|
|
43
|
+
!value || allowable_values.include?(value)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
48
|
+
def self.attribute_map
|
|
49
|
+
{
|
|
50
|
+
:'related_object_type' => :'related_object_type',
|
|
51
|
+
:'related_object_id' => :'related_object_id'
|
|
52
|
+
}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Returns all the JSON keys this model knows about
|
|
56
|
+
def self.acceptable_attributes
|
|
57
|
+
attribute_map.values
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Attribute type mapping.
|
|
61
|
+
def self.openapi_types
|
|
62
|
+
{
|
|
63
|
+
:'related_object_type' => :'String',
|
|
64
|
+
:'related_object_id' => :'String'
|
|
65
|
+
}
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# List of attributes with nullable: true
|
|
69
|
+
def self.openapi_nullable
|
|
70
|
+
Set.new([
|
|
71
|
+
])
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Initializes the object
|
|
75
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
76
|
+
def initialize(attributes = {})
|
|
77
|
+
if (!attributes.is_a?(Hash))
|
|
78
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRulesAssignmentsCreateRequestBody` initialize method"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
82
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
83
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
84
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRulesAssignmentsCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
85
|
+
end
|
|
86
|
+
h[k.to_sym] = v
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if attributes.key?(:'related_object_type')
|
|
90
|
+
self.related_object_type = attributes[:'related_object_type']
|
|
91
|
+
else
|
|
92
|
+
self.related_object_type = 'voucher'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
if attributes.key?(:'related_object_id')
|
|
96
|
+
self.related_object_id = attributes[:'related_object_id']
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
101
|
+
# @return Array for valid properties with the reasons
|
|
102
|
+
def list_invalid_properties
|
|
103
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
104
|
+
invalid_properties = Array.new
|
|
105
|
+
invalid_properties
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Check to see if the all the properties in the model are valid
|
|
109
|
+
# @return true if the model is valid
|
|
110
|
+
def valid?
|
|
111
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
112
|
+
related_object_type_validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier", "campaign", "earning_rule", "distribution", "reward_assignment"])
|
|
113
|
+
return false unless related_object_type_validator.valid?(@related_object_type)
|
|
114
|
+
true
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
118
|
+
# @param [Object] related_object_type Object to be assigned
|
|
119
|
+
def related_object_type=(related_object_type)
|
|
120
|
+
validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier", "campaign", "earning_rule", "distribution", "reward_assignment"])
|
|
121
|
+
unless validator.valid?(related_object_type)
|
|
122
|
+
fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}."
|
|
123
|
+
end
|
|
124
|
+
@related_object_type = related_object_type
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Checks equality by comparing each attribute.
|
|
128
|
+
# @param [Object] Object to be compared
|
|
129
|
+
def ==(o)
|
|
130
|
+
return true if self.equal?(o)
|
|
131
|
+
self.class == o.class &&
|
|
132
|
+
related_object_type == o.related_object_type &&
|
|
133
|
+
related_object_id == o.related_object_id
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# @see the `==` method
|
|
137
|
+
# @param [Object] Object to be compared
|
|
138
|
+
def eql?(o)
|
|
139
|
+
self == o
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Calculates hash code according to all attributes.
|
|
143
|
+
# @return [Integer] Hash code
|
|
144
|
+
def hash
|
|
145
|
+
[related_object_type, related_object_id].hash
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Builds the object from hash
|
|
149
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
150
|
+
# @return [Object] Returns the model itself
|
|
151
|
+
def self.build_from_hash(attributes)
|
|
152
|
+
return nil unless attributes.is_a?(Hash)
|
|
153
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
154
|
+
transformed_hash = {}
|
|
155
|
+
openapi_types.each_pair do |key, type|
|
|
156
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
157
|
+
transformed_hash["#{key}"] = nil
|
|
158
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
159
|
+
# check to ensure the input is an array given that the attribute
|
|
160
|
+
# is documented as an array but the input is not
|
|
161
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
162
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
163
|
+
end
|
|
164
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
165
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
new(transformed_hash)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Deserializes the data based on type
|
|
172
|
+
# @param string type Data type
|
|
173
|
+
# @param string value Value to be deserialized
|
|
174
|
+
# @return [Object] Deserialized data
|
|
175
|
+
def self._deserialize(type, value)
|
|
176
|
+
case type.to_sym
|
|
177
|
+
when :Time
|
|
178
|
+
Time.parse(value)
|
|
179
|
+
when :Date
|
|
180
|
+
Date.parse(value)
|
|
181
|
+
when :String
|
|
182
|
+
value.to_s
|
|
183
|
+
when :Integer
|
|
184
|
+
value.to_i
|
|
185
|
+
when :Float
|
|
186
|
+
value.to_f
|
|
187
|
+
when :Boolean
|
|
188
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
189
|
+
true
|
|
190
|
+
else
|
|
191
|
+
false
|
|
192
|
+
end
|
|
193
|
+
when :Object
|
|
194
|
+
# generic object (usually a Hash), return directly
|
|
195
|
+
value
|
|
196
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
197
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
198
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
199
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
200
|
+
k_type = Regexp.last_match[:k_type]
|
|
201
|
+
v_type = Regexp.last_match[:v_type]
|
|
202
|
+
{}.tap do |hash|
|
|
203
|
+
value.each do |k, v|
|
|
204
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
else # model
|
|
208
|
+
# models (e.g. Pet) or oneOf
|
|
209
|
+
klass = VoucherifySdk.const_get(type)
|
|
210
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Returns the string representation of the object
|
|
215
|
+
# @return [String] String presentation of the object
|
|
216
|
+
def to_s
|
|
217
|
+
to_hash.to_s
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
221
|
+
# @return [Hash] Returns the object in the form of hash
|
|
222
|
+
def to_body
|
|
223
|
+
to_hash
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Returns the object in the form of hash
|
|
227
|
+
# @return [Hash] Returns the object in the form of hash
|
|
228
|
+
def to_hash
|
|
229
|
+
hash = {}
|
|
230
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
231
|
+
value = self.send(attr)
|
|
232
|
+
if value.nil?
|
|
233
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
234
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
hash[param] = _to_hash(value)
|
|
238
|
+
end
|
|
239
|
+
hash
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
# Outputs non-array value in the form of hash
|
|
243
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
244
|
+
# @param [Object] value Any valid value
|
|
245
|
+
# @return [Hash] Returns the value in the form of hash
|
|
246
|
+
def _to_hash(value)
|
|
247
|
+
if value.is_a?(Array)
|
|
248
|
+
value.compact.map { |v| _to_hash(v) }
|
|
249
|
+
elsif value.is_a?(Hash)
|
|
250
|
+
{}.tap do |hash|
|
|
251
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
252
|
+
end
|
|
253
|
+
elsif value.respond_to? :to_hash
|
|
254
|
+
value.to_hash
|
|
255
|
+
else
|
|
256
|
+
value
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
end
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Voucherify API
|
|
3
|
+
|
|
4
|
+
#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: v2018-08-01
|
|
7
|
+
Contact: support@voucherify.io
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
OpenAPI Generator version: 7.0.1
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module VoucherifySdk
|
|
17
|
+
# Response body for **POST** `/validation-rules/{validationRuleId}/assignments`.
|
|
18
|
+
class ValidationRulesAssignmentsCreateResponseBody
|
|
19
|
+
# Validation rule assignment ID.
|
|
20
|
+
attr_accessor :id
|
|
21
|
+
|
|
22
|
+
# Validation rule ID.
|
|
23
|
+
attr_accessor :rule_id
|
|
24
|
+
|
|
25
|
+
# The resource ID to which the validation rule was assigned.
|
|
26
|
+
attr_accessor :related_object_id
|
|
27
|
+
|
|
28
|
+
# The type of resource to which the validation rule was assigned.
|
|
29
|
+
attr_accessor :related_object_type
|
|
30
|
+
|
|
31
|
+
# Timestamp representing the date and time when the validation rule assignment was created in ISO 8601 format.
|
|
32
|
+
attr_accessor :created_at
|
|
33
|
+
|
|
34
|
+
# The type of object represented by the ID.
|
|
35
|
+
attr_accessor :object
|
|
36
|
+
|
|
37
|
+
class EnumAttributeValidator
|
|
38
|
+
attr_reader :datatype
|
|
39
|
+
attr_reader :allowable_values
|
|
40
|
+
|
|
41
|
+
def initialize(datatype, allowable_values)
|
|
42
|
+
@allowable_values = allowable_values.map do |value|
|
|
43
|
+
case datatype.to_s
|
|
44
|
+
when /Integer/i
|
|
45
|
+
value.to_i
|
|
46
|
+
when /Float/i
|
|
47
|
+
value.to_f
|
|
48
|
+
else
|
|
49
|
+
value
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def valid?(value)
|
|
55
|
+
!value || allowable_values.include?(value)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
60
|
+
def self.attribute_map
|
|
61
|
+
{
|
|
62
|
+
:'id' => :'id',
|
|
63
|
+
:'rule_id' => :'rule_id',
|
|
64
|
+
:'related_object_id' => :'related_object_id',
|
|
65
|
+
:'related_object_type' => :'related_object_type',
|
|
66
|
+
:'created_at' => :'created_at',
|
|
67
|
+
:'object' => :'object'
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Returns all the JSON keys this model knows about
|
|
72
|
+
def self.acceptable_attributes
|
|
73
|
+
attribute_map.values
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Attribute type mapping.
|
|
77
|
+
def self.openapi_types
|
|
78
|
+
{
|
|
79
|
+
:'id' => :'String',
|
|
80
|
+
:'rule_id' => :'String',
|
|
81
|
+
:'related_object_id' => :'String',
|
|
82
|
+
:'related_object_type' => :'String',
|
|
83
|
+
:'created_at' => :'Time',
|
|
84
|
+
:'object' => :'String'
|
|
85
|
+
}
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# List of attributes with nullable: true
|
|
89
|
+
def self.openapi_nullable
|
|
90
|
+
Set.new([
|
|
91
|
+
])
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# List of class defined in allOf (OpenAPI v3)
|
|
95
|
+
def self.openapi_all_of
|
|
96
|
+
[
|
|
97
|
+
:'ValidationRuleAssignment'
|
|
98
|
+
]
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Initializes the object
|
|
102
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
103
|
+
def initialize(attributes = {})
|
|
104
|
+
if (!attributes.is_a?(Hash))
|
|
105
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRulesAssignmentsCreateResponseBody` initialize method"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
109
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
110
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
111
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRulesAssignmentsCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
112
|
+
end
|
|
113
|
+
h[k.to_sym] = v
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if attributes.key?(:'id')
|
|
117
|
+
self.id = attributes[:'id']
|
|
118
|
+
else
|
|
119
|
+
self.id = nil
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
if attributes.key?(:'rule_id')
|
|
123
|
+
self.rule_id = attributes[:'rule_id']
|
|
124
|
+
else
|
|
125
|
+
self.rule_id = nil
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
if attributes.key?(:'related_object_id')
|
|
129
|
+
self.related_object_id = attributes[:'related_object_id']
|
|
130
|
+
else
|
|
131
|
+
self.related_object_id = nil
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
if attributes.key?(:'related_object_type')
|
|
135
|
+
self.related_object_type = attributes[:'related_object_type']
|
|
136
|
+
else
|
|
137
|
+
self.related_object_type = nil
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
if attributes.key?(:'created_at')
|
|
141
|
+
self.created_at = attributes[:'created_at']
|
|
142
|
+
else
|
|
143
|
+
self.created_at = nil
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
if attributes.key?(:'object')
|
|
147
|
+
self.object = attributes[:'object']
|
|
148
|
+
else
|
|
149
|
+
self.object = 'validation_rules_assignment'
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
154
|
+
# @return Array for valid properties with the reasons
|
|
155
|
+
def list_invalid_properties
|
|
156
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
157
|
+
invalid_properties = Array.new
|
|
158
|
+
if @id.nil?
|
|
159
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
if @rule_id.nil?
|
|
163
|
+
invalid_properties.push('invalid value for "rule_id", rule_id cannot be nil.')
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
if @related_object_id.nil?
|
|
167
|
+
invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.')
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
if @related_object_type.nil?
|
|
171
|
+
invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.')
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
if @created_at.nil?
|
|
175
|
+
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
if @object.nil?
|
|
179
|
+
invalid_properties.push('invalid value for "object", object cannot be nil.')
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
invalid_properties
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Check to see if the all the properties in the model are valid
|
|
186
|
+
# @return true if the model is valid
|
|
187
|
+
def valid?
|
|
188
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
189
|
+
return false if @id.nil?
|
|
190
|
+
return false if @rule_id.nil?
|
|
191
|
+
return false if @related_object_id.nil?
|
|
192
|
+
return false if @related_object_type.nil?
|
|
193
|
+
related_object_type_validator = EnumAttributeValidator.new('String', ["voucher", "campaign", "earning_rule", "reward_assignment", "promotion_tier", "distribution"])
|
|
194
|
+
return false unless related_object_type_validator.valid?(@related_object_type)
|
|
195
|
+
return false if @created_at.nil?
|
|
196
|
+
return false if @object.nil?
|
|
197
|
+
object_validator = EnumAttributeValidator.new('String', ["validation_rules_assignment"])
|
|
198
|
+
return false unless object_validator.valid?(@object)
|
|
199
|
+
true
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
203
|
+
# @param [Object] related_object_type Object to be assigned
|
|
204
|
+
def related_object_type=(related_object_type)
|
|
205
|
+
validator = EnumAttributeValidator.new('String', ["voucher", "campaign", "earning_rule", "reward_assignment", "promotion_tier", "distribution"])
|
|
206
|
+
unless validator.valid?(related_object_type)
|
|
207
|
+
fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}."
|
|
208
|
+
end
|
|
209
|
+
@related_object_type = related_object_type
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
213
|
+
# @param [Object] object Object to be assigned
|
|
214
|
+
def object=(object)
|
|
215
|
+
validator = EnumAttributeValidator.new('String', ["validation_rules_assignment"])
|
|
216
|
+
unless validator.valid?(object)
|
|
217
|
+
fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}."
|
|
218
|
+
end
|
|
219
|
+
@object = object
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# Checks equality by comparing each attribute.
|
|
223
|
+
# @param [Object] Object to be compared
|
|
224
|
+
def ==(o)
|
|
225
|
+
return true if self.equal?(o)
|
|
226
|
+
self.class == o.class &&
|
|
227
|
+
id == o.id &&
|
|
228
|
+
rule_id == o.rule_id &&
|
|
229
|
+
related_object_id == o.related_object_id &&
|
|
230
|
+
related_object_type == o.related_object_type &&
|
|
231
|
+
created_at == o.created_at &&
|
|
232
|
+
object == o.object
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
# @see the `==` method
|
|
236
|
+
# @param [Object] Object to be compared
|
|
237
|
+
def eql?(o)
|
|
238
|
+
self == o
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Calculates hash code according to all attributes.
|
|
242
|
+
# @return [Integer] Hash code
|
|
243
|
+
def hash
|
|
244
|
+
[id, rule_id, related_object_id, related_object_type, created_at, object].hash
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# Builds the object from hash
|
|
248
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
249
|
+
# @return [Object] Returns the model itself
|
|
250
|
+
def self.build_from_hash(attributes)
|
|
251
|
+
return nil unless attributes.is_a?(Hash)
|
|
252
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
253
|
+
transformed_hash = {}
|
|
254
|
+
openapi_types.each_pair do |key, type|
|
|
255
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
256
|
+
transformed_hash["#{key}"] = nil
|
|
257
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
258
|
+
# check to ensure the input is an array given that the attribute
|
|
259
|
+
# is documented as an array but the input is not
|
|
260
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
261
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
262
|
+
end
|
|
263
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
264
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
new(transformed_hash)
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# Deserializes the data based on type
|
|
271
|
+
# @param string type Data type
|
|
272
|
+
# @param string value Value to be deserialized
|
|
273
|
+
# @return [Object] Deserialized data
|
|
274
|
+
def self._deserialize(type, value)
|
|
275
|
+
case type.to_sym
|
|
276
|
+
when :Time
|
|
277
|
+
Time.parse(value)
|
|
278
|
+
when :Date
|
|
279
|
+
Date.parse(value)
|
|
280
|
+
when :String
|
|
281
|
+
value.to_s
|
|
282
|
+
when :Integer
|
|
283
|
+
value.to_i
|
|
284
|
+
when :Float
|
|
285
|
+
value.to_f
|
|
286
|
+
when :Boolean
|
|
287
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
288
|
+
true
|
|
289
|
+
else
|
|
290
|
+
false
|
|
291
|
+
end
|
|
292
|
+
when :Object
|
|
293
|
+
# generic object (usually a Hash), return directly
|
|
294
|
+
value
|
|
295
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
296
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
297
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
298
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
299
|
+
k_type = Regexp.last_match[:k_type]
|
|
300
|
+
v_type = Regexp.last_match[:v_type]
|
|
301
|
+
{}.tap do |hash|
|
|
302
|
+
value.each do |k, v|
|
|
303
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
else # model
|
|
307
|
+
# models (e.g. Pet) or oneOf
|
|
308
|
+
klass = VoucherifySdk.const_get(type)
|
|
309
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
# Returns the string representation of the object
|
|
314
|
+
# @return [String] String presentation of the object
|
|
315
|
+
def to_s
|
|
316
|
+
to_hash.to_s
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
320
|
+
# @return [Hash] Returns the object in the form of hash
|
|
321
|
+
def to_body
|
|
322
|
+
to_hash
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
# Returns the object in the form of hash
|
|
326
|
+
# @return [Hash] Returns the object in the form of hash
|
|
327
|
+
def to_hash
|
|
328
|
+
hash = {}
|
|
329
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
330
|
+
value = self.send(attr)
|
|
331
|
+
if value.nil?
|
|
332
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
333
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
hash[param] = _to_hash(value)
|
|
337
|
+
end
|
|
338
|
+
hash
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
# Outputs non-array value in the form of hash
|
|
342
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
343
|
+
# @param [Object] value Any valid value
|
|
344
|
+
# @return [Hash] Returns the value in the form of hash
|
|
345
|
+
def _to_hash(value)
|
|
346
|
+
if value.is_a?(Array)
|
|
347
|
+
value.compact.map { |v| _to_hash(v) }
|
|
348
|
+
elsif value.is_a?(Hash)
|
|
349
|
+
{}.tap do |hash|
|
|
350
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
351
|
+
end
|
|
352
|
+
elsif value.respond_to? :to_hash
|
|
353
|
+
value.to_hash
|
|
354
|
+
else
|
|
355
|
+
value
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
end
|
data/lib/VoucherifySdk.rb
CHANGED
|
@@ -618,6 +618,8 @@ require 'VoucherifySdk/models/validation_rule_assignments_list'
|
|
|
618
618
|
require 'VoucherifySdk/models/validation_rule_base'
|
|
619
619
|
require 'VoucherifySdk/models/validation_rule_base_applicable_to'
|
|
620
620
|
require 'VoucherifySdk/models/validation_rule_base_error'
|
|
621
|
+
require 'VoucherifySdk/models/validation_rules_assignments_create_request_body'
|
|
622
|
+
require 'VoucherifySdk/models/validation_rules_assignments_create_response_body'
|
|
621
623
|
require 'VoucherifySdk/models/validation_rules_assignments_list'
|
|
622
624
|
require 'VoucherifySdk/models/validation_rules_assignments_list_response_body'
|
|
623
625
|
require 'VoucherifySdk/models/validation_rules_create_request_body'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: voucherify
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.0.
|
|
4
|
+
version: 5.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- pawelrychlik
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-05-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: typhoeus
|
|
@@ -57,6 +57,7 @@ executables: []
|
|
|
57
57
|
extensions: []
|
|
58
58
|
extra_rdoc_files: []
|
|
59
59
|
files:
|
|
60
|
+
- CHANGELOG.md
|
|
60
61
|
- Dockerfile
|
|
61
62
|
- ENDPOINTS-COVERAGE.md
|
|
62
63
|
- EXAMPLES.md
|
|
@@ -84,6 +85,7 @@ files:
|
|
|
84
85
|
- __tests__/spec/7_vouchers_spec.rb
|
|
85
86
|
- __tests__/spec/8_events_spec.rb
|
|
86
87
|
- __tests__/spec/9_redemptions_spec.rb
|
|
88
|
+
- __tests__/spec/a1_validation_rules_spec.rb
|
|
87
89
|
- docs/Any.md
|
|
88
90
|
- docs/ApplicableTo.md
|
|
89
91
|
- docs/ApplicableToEffect.md
|
|
@@ -711,6 +713,8 @@ files:
|
|
|
711
713
|
- docs/ValidationRuleBaseApplicableTo.md
|
|
712
714
|
- docs/ValidationRuleBaseError.md
|
|
713
715
|
- docs/ValidationRulesApi.md
|
|
716
|
+
- docs/ValidationRulesAssignmentsCreateRequestBody.md
|
|
717
|
+
- docs/ValidationRulesAssignmentsCreateResponseBody.md
|
|
714
718
|
- docs/ValidationRulesAssignmentsList.md
|
|
715
719
|
- docs/ValidationRulesAssignmentsListResponseBody.md
|
|
716
720
|
- docs/ValidationRulesCreateRequestBody.md
|
|
@@ -1397,6 +1401,8 @@ files:
|
|
|
1397
1401
|
- lib/VoucherifySdk/models/validation_rule_base.rb
|
|
1398
1402
|
- lib/VoucherifySdk/models/validation_rule_base_applicable_to.rb
|
|
1399
1403
|
- lib/VoucherifySdk/models/validation_rule_base_error.rb
|
|
1404
|
+
- lib/VoucherifySdk/models/validation_rules_assignments_create_request_body.rb
|
|
1405
|
+
- lib/VoucherifySdk/models/validation_rules_assignments_create_response_body.rb
|
|
1400
1406
|
- lib/VoucherifySdk/models/validation_rules_assignments_list.rb
|
|
1401
1407
|
- lib/VoucherifySdk/models/validation_rules_assignments_list_response_body.rb
|
|
1402
1408
|
- lib/VoucherifySdk/models/validation_rules_create_request_body.rb
|
|
@@ -1489,3 +1495,4 @@ test_files:
|
|
|
1489
1495
|
- __tests__/spec/7_vouchers_spec.rb
|
|
1490
1496
|
- __tests__/spec/8_events_spec.rb
|
|
1491
1497
|
- __tests__/spec/9_redemptions_spec.rb
|
|
1498
|
+
- __tests__/spec/a1_validation_rules_spec.rb
|