Skip to content

Commit

Permalink
Merge pull request #62 from voucherifyio/v5.0.1
Browse files Browse the repository at this point in the history
V5.0.1
  • Loading branch information
marcin-slezak authored May 9, 2024
2 parents 6e9e4e7 + f27e424 commit a77b09f
Show file tree
Hide file tree
Showing 14 changed files with 841 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /app
COPY . .

RUN gem build VoucherifySdk.gemspec
RUN gem install voucherify-5.0.0.gem
RUN gem install voucherify-5.0.1.gem
RUN gem install dotenv
RUN gem install rspec

Expand Down
6 changes: 3 additions & 3 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ gem build VoucherifySdk.gemspec
Then either install the gem locally:

```shell
gem install ./VoucherifySdk-1.0.0.gem
gem install ./VoucherifySdk-5.0.1.gem
```

(for development, run `gem install --dev ./VoucherifySdk-1.0.0.gem` to install the development dependencies)
(for development, run `gem install --dev ./VoucherifySdk-5.0.1.gem` to install the development dependencies)

Add this to the Gemfile:

```shell
gem 'VoucherifySdk', '~> 1.0.0'
gem 'VoucherifySdk', '~> 5.0.1'
```

Then install dependencies with bundler
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,13 @@ Read more about how to Contribute to Voucherify Ruby SDK by visiting main repo [

Remember that this SDK is auto generated (except of the tests) so changes made here will be overwritten by generator.

## Changelog
## 📅 Changelog

- **2022-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.
- **2024-05-08** - `5.0.1` - Added support for [Create validation rule assignment](https://docs.voucherify.io/reference/create-validation-rule-assignment)

*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).*
- **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.

*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).*

*Changelog for previous versions could be found in the [CHANGELOG.md file](./CHANGELOG.md)*

Expand Down Expand Up @@ -262,6 +264,7 @@ Class | Method | HTTP request | Description
*VoucherifySdk::RewardsApi* | [**list_reward_assignments**](docs/RewardsApi.md#list_reward_assignments) | **GET** /v1/rewards/{rewardId}/assignments | List Reward Assignments
*VoucherifySdk::RewardsApi* | [**update_reward_assignment**](docs/RewardsApi.md#update_reward_assignment) | **PUT** /v1/rewards/{rewardId}/assignments/{assignmentId} | Update Reward Assignment
*VoucherifySdk::SegmentsApi* | [**delete_segment**](docs/SegmentsApi.md#delete_segment) | **DELETE** /v1/segments/{segmentId} | Delete Segment
*VoucherifySdk::ValidationRulesApi* | [**create_validation_rule_assignment**](docs/ValidationRulesApi.md#create_validation_rule_assignment) | **POST** /v1/validation-rules/{validationRuleId}/assignments | Create Validation Rules Assignments
*VoucherifySdk::ValidationRulesApi* | [**create_validation_rules**](docs/ValidationRulesApi.md#create_validation_rules) | **POST** /v1/validation-rules | Create Validation Rules
*VoucherifySdk::ValidationRulesApi* | [**delete_validation_rule_assignment**](docs/ValidationRulesApi.md#delete_validation_rule_assignment) | **DELETE** /v1/validation-rules/{validationRuleId}/assignments/{assignmentId} | Delete Validation Rule Assignment
*VoucherifySdk::ValidationRulesApi* | [**delete_validation_rules**](docs/ValidationRulesApi.md#delete_validation_rules) | **DELETE** /v1/validation-rules/{validationRuleId} | Delete Validation Rule
Expand Down Expand Up @@ -885,6 +888,8 @@ Class | Method | HTTP request | Description
- [VoucherifySdk::ValidationRuleBase](docs/ValidationRuleBase.md)
- [VoucherifySdk::ValidationRuleBaseApplicableTo](docs/ValidationRuleBaseApplicableTo.md)
- [VoucherifySdk::ValidationRuleBaseError](docs/ValidationRuleBaseError.md)
- [VoucherifySdk::ValidationRulesAssignmentsCreateRequestBody](docs/ValidationRulesAssignmentsCreateRequestBody.md)
- [VoucherifySdk::ValidationRulesAssignmentsCreateResponseBody](docs/ValidationRulesAssignmentsCreateResponseBody.md)
- [VoucherifySdk::ValidationRulesAssignmentsList](docs/ValidationRulesAssignmentsList.md)
- [VoucherifySdk::ValidationRulesAssignmentsListResponseBody](docs/ValidationRulesAssignmentsListResponseBody.md)
- [VoucherifySdk::ValidationRulesCreateRequestBody](docs/ValidationRulesCreateRequestBody.md)
Expand Down Expand Up @@ -943,7 +948,3 @@ Class | Method | HTTP request | Description
- [VoucherifySdk::VouchersTransactionsExportCreateResponseBody](docs/VouchersTransactionsExportCreateResponseBody.md)
- [VoucherifySdk::VouchersTransactionsListResponseBody](docs/VouchersTransactionsListResponseBody.md)


## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
9 changes: 9 additions & 0 deletions __tests__/lib/voucherify_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def initialize
@loyalty_card = nil
@product_ids = []
@sku = nil
@validation_rule = nil
end

def set_discount_campaign(discount_campaign)
Expand All @@ -37,6 +38,10 @@ def add_product_id(product_id)
@product_ids.push(product_id)
end

def set_validation_rule(validation_rule)
@validation_rule = validation_rule
end

def get_product_ids
@product_ids
end
Expand Down Expand Up @@ -89,6 +94,10 @@ def get_loyalty_card
@loyalty_card
end

def get_validation_rule
@validation_rule
end

def set_loyalty_card(loyalty_card)
@loyalty_card = loyalty_card
end
Expand Down
2 changes: 1 addition & 1 deletion __tests__/spec/2_campaigns_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
$created_promotion_campaign = nil
$created_loyalty_campaign = nil
$created_validation_rule_applicable_to = nil
$created_campaign_with_validation_rule = nil

it 'create a validation rule with applicable_to', :order => :first do
validation_rule = create_validation_rule_applicable_to(@validation_rules_api_instance, @voucherify_data.get_product.id)

expect(validation_rule).not_to be_nil

$created_validation_rule_applicable_to = validation_rule
@voucherify_data.set_validation_rule(validation_rule)
end

it 'create a discount campaign with applicable_to validation rule', :order => :second do
Expand Down
33 changes: 33 additions & 0 deletions __tests__/spec/a1_validation_rules_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require_relative '../lib/config.rb'
require_relative '../lib/voucherify_data.rb'
require 'VoucherifySdk'

RSpec.describe 'Validation Rules API', :order => :defined do
before(:each) do
@validation_rules_api_instance = Config.validation_rules_api_instance()
@voucherify_data = VoucherifyData.instance()
end

it 'create validation rule', :order => :first do
voucher = @voucherify_data.get_voucher()
validation_rule = @voucherify_data.get_validation_rule()

validationRulesAssignmentsCreateRequestBody = VoucherifySdk::ValidationRulesAssignmentsCreateRequestBody.new({
related_object_type: "voucher",
related_object_id: voucher.code
})

created_validation_rule_assignment = @validation_rules_api_instance.create_validation_rule_assignment(validation_rule.id, {
validation_rules_assignments_create_request_body: validationRulesAssignmentsCreateRequestBody
})

expect(created_validation_rule_assignment).not_to be_nil
expect(created_validation_rule_assignment.id).not_to be_nil
expect(created_validation_rule_assignment.created_at).not_to be_nil
expect(created_validation_rule_assignment.rule_id).to eq(validation_rule.id)
expect(created_validation_rule_assignment.related_object_id).to eq(voucher.id)
expect(created_validation_rule_assignment.related_object_type).to eq("voucher")
expect(created_validation_rule_assignment.object).to eq("validation_rules_assignment")
end

end
65 changes: 65 additions & 0 deletions docs/ValidationRulesApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All URIs are relative to *https://api.voucherify.io*

| Method | HTTP request | Description |
| ------ | ------------ | ----------- |
| [**create_validation_rule_assignment**](ValidationRulesApi.md#create_validation_rule_assignment) | **POST** /v1/validation-rules/{validationRuleId}/assignments | Create Validation Rules Assignments |
| [**create_validation_rules**](ValidationRulesApi.md#create_validation_rules) | **POST** /v1/validation-rules | Create Validation Rules |
| [**delete_validation_rule_assignment**](ValidationRulesApi.md#delete_validation_rule_assignment) | **DELETE** /v1/validation-rules/{validationRuleId}/assignments/{assignmentId} | Delete Validation Rule Assignment |
| [**delete_validation_rules**](ValidationRulesApi.md#delete_validation_rules) | **DELETE** /v1/validation-rules/{validationRuleId} | Delete Validation Rule |
Expand All @@ -14,6 +15,70 @@ All URIs are relative to *https://api.voucherify.io*
| [**update_validation_rule**](ValidationRulesApi.md#update_validation_rule) | **PUT** /v1/validation-rules/{validationRuleId} | Update Validation Rule |


## create_validation_rule_assignment

> <ValidationRulesAssignmentsCreateResponseBody> create_validation_rule_assignment(validation_rule_id, opts)
Create Validation Rules Assignments

Assign validation rule to either one of the following objects: voucher, campaign, promotion tier, earning rule, reward, distribution.

### Examples

```ruby
require 'time'
require 'VoucherifySdk'
# setup authorization
VoucherifySdk.configure do |config|
# Configure API key authorization: X-App-Id
config.api_key['X-App-Id'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['X-App-Id'] = 'Bearer'

# Configure API key authorization: X-App-Token
config.api_key['X-App-Token'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['X-App-Token'] = 'Bearer'
end

api_instance = VoucherifySdk::ValidationRulesApi.new
validation_rule_id = 'validation_rule_id_example' # String | Unique validation rule ID.
opts = {
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.
validation_rules_assignments_create_request_body: VoucherifySdk::ValidationRulesAssignmentsCreateRequestBody.new # ValidationRulesAssignmentsCreateRequestBody | Specify the resource that you would like to assign the validation rule to.
}

begin
# Create Validation Rules Assignments
result = api_instance.create_validation_rule_assignment(validation_rule_id, opts)
p result
rescue VoucherifySdk::ApiError => e
puts "Error when calling ValidationRulesApi->create_validation_rule_assignment: #{e}"
end
```

### Parameters

| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **validation_rule_id** | **String** | Unique validation rule ID. | |
| **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] |
| **validation_rules_assignments_create_request_body** | [**ValidationRulesAssignmentsCreateRequestBody**](ValidationRulesAssignmentsCreateRequestBody.md) | Specify the resource that you would like to assign the validation rule to. | [optional] |

### Return type

[**ValidationRulesAssignmentsCreateResponseBody**](ValidationRulesAssignmentsCreateResponseBody.md)

### Authorization

[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token)

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json


## create_validation_rules

> <ValidationRulesCreateResponseBody> create_validation_rules(opts)
Expand Down
9 changes: 9 additions & 0 deletions docs/ValidationRulesAssignmentsCreateRequestBody.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# VoucherifySdk::ValidationRulesAssignmentsCreateRequestBody

## Properties

| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **related_object_type** | **String** | Defines the related object. i.e. &#x60;voucher&#x60;. | [optional][default to &#39;voucher&#39;] |
| **related_object_id** | **String** | Unique related object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. | [optional] |

13 changes: 13 additions & 0 deletions docs/ValidationRulesAssignmentsCreateResponseBody.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# VoucherifySdk::ValidationRulesAssignmentsCreateResponseBody

## Properties

| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **id** | **String** | Validation rule assignment ID. | |
| **rule_id** | **String** | Validation rule ID. | |
| **related_object_id** | **String** | The resource ID to which the validation rule was assigned. | |
| **related_object_type** | **String** | The type of resource to which the validation rule was assigned. | |
| **created_at** | **Time** | Timestamp representing the date and time when the validation rule assignment was created in ISO 8601 format. | |
| **object** | **String** | The type of object represented by the ID. | [default to &#39;validation_rules_assignment&#39;] |

2 changes: 2 additions & 0 deletions lib/VoucherifySdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,8 @@
require 'VoucherifySdk/models/validation_rule_base'
require 'VoucherifySdk/models/validation_rule_base_applicable_to'
require 'VoucherifySdk/models/validation_rule_base_error'
require 'VoucherifySdk/models/validation_rules_assignments_create_request_body'
require 'VoucherifySdk/models/validation_rules_assignments_create_response_body'
require 'VoucherifySdk/models/validation_rules_assignments_list'
require 'VoucherifySdk/models/validation_rules_assignments_list_response_body'
require 'VoucherifySdk/models/validation_rules_create_request_body'
Expand Down
73 changes: 73 additions & 0 deletions lib/VoucherifySdk/api/validation_rules_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,79 @@ class ValidationRulesApi
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Create Validation Rules Assignments
# Assign validation rule to either one of the following objects: voucher, campaign, promotion tier, earning rule, reward, distribution.
# @param validation_rule_id [String] Unique validation rule ID.
# @param [Hash] opts the optional parameters
# @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.
# @option opts [ValidationRulesAssignmentsCreateRequestBody] :validation_rules_assignments_create_request_body Specify the resource that you would like to assign the validation rule to.
# @return [ValidationRulesAssignmentsCreateResponseBody]
def create_validation_rule_assignment(validation_rule_id, opts = {})
data, _status_code, _headers = create_validation_rule_assignment_with_http_info(validation_rule_id, opts)
data
end

# Create Validation Rules Assignments
# Assign validation rule to either one of the following objects: voucher, campaign, promotion tier, earning rule, reward, distribution.
# @param validation_rule_id [String] Unique validation rule ID.
# @param [Hash] opts the optional parameters
# @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.
# @option opts [ValidationRulesAssignmentsCreateRequestBody] :validation_rules_assignments_create_request_body Specify the resource that you would like to assign the validation rule to.
# @return [Array<(ValidationRulesAssignmentsCreateResponseBody, Integer, Hash)>] ValidationRulesAssignmentsCreateResponseBody data, response status code and response headers
private def create_validation_rule_assignment_with_http_info(validation_rule_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ValidationRulesApi.create_validation_rule_assignment ...'
end
# verify the required parameter 'validation_rule_id' is set
if @api_client.config.client_side_validation && validation_rule_id.nil?
fail ArgumentError, "Missing the required parameter 'validation_rule_id' when calling ValidationRulesApi.create_validation_rule_assignment"
end
# resource path
local_var_path = '/v1/validation-rules/{validationRuleId}/assignments'.sub('{' + 'validationRuleId' + '}', CGI.escape(validation_rule_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
query_params[:'force'] = opts[:'force'] if !opts[:'force'].nil?

# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end

# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'validation_rules_assignments_create_request_body'])

# return_type
return_type = opts[:debug_return_type] || 'ValidationRulesAssignmentsCreateResponseBody'

# auth_names
auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token']

new_options = opts.merge(
:operation => :"ValidationRulesApi.create_validation_rule_assignment",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)

data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ValidationRulesApi#create_validation_rule_assignment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# Create Validation Rules
# Create validation rules.
# @param [Hash] opts the optional parameters
Expand Down
Loading

0 comments on commit a77b09f

Please sign in to comment.